OSDN Git Service

* Added DL tag.
[modchxj/mod_chxj.git] / src / chxj_hdml.c
1 /*
2  * Copyright (C) 2005-2008 Atsushi Konno All rights reserved.
3  * Copyright (C) 2005 QSDN,Inc. All rights reserved.
4  *
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
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
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.
16  */
17 #include "chxj_hdml.h"
18 #include "chxj_tag_util.h"
19 #include "chxj_str_util.h"
20 #include <unistd.h>
21 #include "chxj_img_conv.h"
22 #include "chxj_dump.h"
23 #include "chxj_qr_code.h"
24 #include "chxj_encoding.h"
25
26 #define CHECK_BOX_PREFIX     "_chxj_c_"
27 #define RADIO_BUTTON_PREFIX  "_chxj_r_"
28 #define SUBMIT_BUTTON_PREFIX "_chxj_s_"
29
30 #define GET_HDML(X) ((hdml_t *)(X))
31
32 static void  s_init_hdml            (hdml_t *hdml, Doc *doc, request_rec *r, device_table *spec);
33
34
35 static char *s_hdml_start_html_tag    (void *pdoc,  Node *node);
36 static char *s_hdml_end_html_tag      (void *pdoc,  Node *node);
37 static char *s_hdml_start_meta_tag    (void *pdoc,  Node *node);
38 static char *s_hdml_end_meta_tag      (void *pdoc,  Node *node);
39 static char *s_hdml_start_li_tag      (void *pdoc,  Node *node);
40 static char *s_hdml_end_li_tag        (void *pdoc,  Node *node);
41 static char *s_hdml_start_head_tag    (void *pdoc,  Node *node);
42 static char *s_hdml_end_head_tag      (void *pdoc,  Node *node);
43 static char *s_hdml_start_title_tag   (void *pdoc,  Node *node);
44 static char *s_hdml_end_title_tag     (void *pdoc,  Node *node);
45 static char *s_hdml_start_base_tag    (void *pdoc,  Node *node);
46 static char *s_hdml_end_base_tag      (void *pdoc,  Node *node);
47 static char *s_hdml_start_body_tag    (void *pdoc,  Node *node);
48 static char *s_hdml_end_body_tag      (void *pdoc,  Node *node);
49 static char *s_hdml_start_a_tag       (void *pdoc,  Node *node);
50 static char *s_hdml_end_a_tag         (void *pdoc,  Node *node);
51 static char *s_hdml_start_br_tag      (void *pdoc,  Node *node);
52 static char *s_hdml_end_br_tag        (void *pdoc,  Node *node);
53 static char *s_hdml_start_tr_tag      (void *pdoc,  Node *node);
54 static char *s_hdml_end_tr_tag        (void *pdoc,  Node *node);
55 static char *s_hdml_start_font_tag    (void *pdoc,  Node *node);
56 static char *s_hdml_end_font_tag      (void *pdoc,  Node *node);
57 static char *s_hdml_start_form_tag    (void *pdoc,  Node *node);
58 static char *s_hdml_end_form_tag      (void *pdoc,  Node *node);
59 static char *s_hdml_start_input_tag   (void *pdoc,  Node *node);
60 static char *s_hdml_end_input_tag     (void *pdoc,  Node *node);
61 static char *s_hdml_start_select_tag  (void *pdoc,  Node *node);
62 static char *s_hdml_end_select_tag    (void *pdoc,  Node *node);
63 static char *s_hdml_start_option_tag  (void *pdoc,  Node *node);
64 static char *s_hdml_end_option_tag    (void *pdoc,  Node *node);
65 static char *s_hdml_start_center_tag  (void *pdoc,  Node *node);
66 static char *s_hdml_end_center_tag    (void *pdoc,  Node *node);
67 static char *s_hdml_start_hr_tag      (void *pdoc,  Node *node);
68 static char *s_hdml_end_hr_tag        (void *pdoc,  Node *node);
69 static char *s_hdml_start_img_tag     (void *pdoc,  Node *node);
70 static char *s_hdml_end_img_tag       (void *pdoc,  Node *node);
71 static char *s_hdml_start_div_tag     (void *pdoc,  Node *node);
72 static char *s_hdml_end_div_tag       (void *pdoc,  Node *node);
73
74 static char *s_get_form_no          (request_rec *r, hdml_t *hdml);
75
76 static void  s_hdml_count_radio_tag (hdml_t *hdml, Node *node) ;
77
78 static void  s_hdml_do_input_text_tag    (hdml_t *hdml, Node *tag);
79 static void  s_hdml_do_input_password_tag(hdml_t *hdml, Node *tag);
80 static void  s_hdml_do_input_submit_tag  (hdml_t *hdml, Node *tag);
81 static void  s_hdml_do_input_hidden_tag  (hdml_t *hdml, Node *tag);
82 static void  s_hdml_do_input_radio_tag   (hdml_t *hdml, Node *tag);
83 static void  s_hdml_do_input_checkbox_tag(hdml_t *hdml, Node *tag);
84 static void  s_hdml_tag_output_upper_half(hdml_t *hdml, Node *node);
85
86 static hdml_t *s_output_to_hdml_out       (hdml_t *hdml, char *s);
87 static hdml_t *s_output_to_hdml_card      (hdml_t *hdml, char *s);
88 static void  s_output_to_postdata         (hdml_t *hdml, char *s);
89 static void  s_output_to_init_vars        (hdml_t *hdml, char *s);
90 static char *s_hdml_chxjif_tag            (void *pdoc, Node *node);
91 static char *s_hdml_text_tag              (void *pdoc, Node *node);
92
93
94 tag_handler hdml_handler[] = {
95   /* tagHTML */
96   {
97     s_hdml_start_html_tag,
98     s_hdml_end_html_tag,
99   },
100   /* tagMETA */
101   {
102     s_hdml_start_meta_tag,
103     s_hdml_end_meta_tag,
104   },
105   /* tagTEXTAREA */
106   {
107     NULL,
108     NULL,
109   },
110   /* tagP */
111   {
112     NULL,
113     NULL,
114   },
115   /* tagPRE */
116   {
117     NULL,
118     NULL,
119   },
120   /* tagUL */
121   {
122     NULL,
123     NULL,
124   },
125   /* tagLI */
126   {
127     s_hdml_start_li_tag,
128     s_hdml_end_li_tag,
129   },
130   /* tagOL */
131   {
132     NULL,
133     NULL,
134   },
135   /* tagH1 */
136   {
137     NULL,
138     NULL,
139   },
140   /* tagH2 */
141   {
142     NULL,
143     NULL,
144   },
145   /* tagH3 */
146   {
147     NULL,
148     NULL,
149   },
150   /* tagH4 */
151   {
152     NULL,
153     NULL,
154   },
155   /* tagH5 */
156   {
157     NULL,
158     NULL,
159   },
160   /* tagH6 */
161   {
162     NULL,
163     NULL,
164   },
165   /* tagHEAD */
166   {
167     s_hdml_start_head_tag,
168     s_hdml_end_head_tag,
169   },
170   /* tagTITLE */
171   {
172     s_hdml_start_title_tag,
173     s_hdml_end_title_tag,
174   },
175   /* tagBASE */
176   {
177     s_hdml_start_base_tag,
178     s_hdml_end_base_tag,
179   },
180   /* tagBODY */
181   {
182     s_hdml_start_body_tag,
183     s_hdml_end_body_tag,
184   },
185   /* tagA */
186   {
187     s_hdml_start_a_tag,
188     s_hdml_end_a_tag,
189   },
190   /* tagBR */
191   {
192     s_hdml_start_br_tag,
193     s_hdml_end_br_tag,
194   },
195   /* tagTABLE */
196   {
197     NULL,
198     NULL,
199   },
200   /* tagTR */
201   {
202     s_hdml_start_tr_tag,
203     s_hdml_end_tr_tag,
204   },
205   /* tagTD */
206   {
207     NULL,
208     NULL,
209   },
210   /* tagTBODY */
211   {
212     NULL,
213     NULL,
214   },
215   /* tagFONT */
216   {
217     s_hdml_start_font_tag,
218     s_hdml_end_font_tag,
219   },
220   /* tagFORM */
221   {
222     s_hdml_start_form_tag,
223     s_hdml_end_form_tag,
224   },
225   /* tagINPUT */
226   {
227     s_hdml_start_input_tag,
228     s_hdml_end_input_tag,
229   },
230   /* tagCENTER */
231   {
232     s_hdml_start_center_tag,
233     s_hdml_end_center_tag,
234   },
235   /* tagHR */
236   {
237     s_hdml_start_hr_tag,
238     s_hdml_end_hr_tag,
239   },
240   /* tagIMG */
241   {
242     s_hdml_start_img_tag,
243     s_hdml_end_img_tag,
244   },
245   /* tagSELECT */
246   {
247     s_hdml_start_select_tag,
248     s_hdml_end_select_tag,
249   },
250   /* tagOPTION */
251   {
252     s_hdml_start_option_tag,
253     s_hdml_end_option_tag,
254   },
255   /* tagDIV */
256   {
257     s_hdml_start_div_tag,
258     s_hdml_end_div_tag,
259   },
260   /* tagCHXJIF */
261   {
262     s_hdml_chxjif_tag,
263     NULL,
264   },
265   /* tagNOBR */
266   {
267     NULL,
268     NULL,
269   },
270   /* tagSMALL */
271   {
272     NULL,
273     NULL,
274   },
275   /* tagSTYLE */
276   {
277     NULL,
278     NULL,
279   },
280   /* tagSPAN */
281   {
282     NULL,
283     NULL,
284   },
285   /* tagTEXT */
286   {
287     s_hdml_text_tag,
288     NULL,
289   },
290   /* tagTH */
291   {
292     NULL,
293     NULL,
294   },
295   /* tagB */
296   {
297     NULL,
298     NULL,
299   },
300   /* tagFIELDSET */
301   {
302     NULL,
303     NULL,
304   },
305   /* tagDT */
306   {
307     NULL,
308     NULL,
309   },
310   /* tagLEGEND */
311   {
312     NULL,
313     NULL,
314   },
315   /* tagLABEL */
316   {
317     NULL,
318     NULL,
319   },
320   /* tagDL */
321   {
322     NULL,     /* not support */
323     NULL,     /* not support */
324   },
325   /* tagDD */
326   {
327     NULL,
328     NULL,
329   },
330 };
331
332 /**
333  * converts from CHTML to hdml.
334  *
335  * @param r    [i] Requet_rec is appointed.
336  * @param spec [i] The result of the device specification processing which 
337  *                 was done in advance is appointed.
338  * @param src  [i] The character string before the converting is appointed.
339  * @return         The character string after the converting is returned.
340  */
341 char *
342 chxj_convert_hdml(
343   request_rec         *r, 
344   device_table        *spec, 
345   const char          *src, 
346   apr_size_t          srclen, 
347   apr_size_t          *dstlen,
348   chxjconvrule_entry  *entryp,
349   cookie_t            *UNUSED(cookie)
350 )
351 {
352   char      *dst;
353   char      *buf;
354   Doc       doc;
355   hdml_t    hdml;
356
357   dst = NULL;
358   buf = NULL;
359
360   /*--------------------------------------------------------------------------*/
361   /* If qrcode xml                                                            */
362   /*--------------------------------------------------------------------------*/
363   *dstlen = srclen;
364   dst = chxj_qr_code_blob_handler(r, src, (size_t*)dstlen);
365   if (dst) {
366     DBG(r,"i found qrcode xml");
367     return dst;
368   }
369   DBG(r,"not found qrcode xml");
370
371   /*--------------------------------------------------------------------------*/
372   /* initialize hdml structure                                                */
373   /*--------------------------------------------------------------------------*/
374   s_init_hdml(&hdml,&doc,r, spec);
375
376   hdml.entryp = entryp;
377
378   ap_set_content_type(r, "text/x-hdml; charset=Shift_JIS");
379   /*--------------------------------------------------------------------------*/
380   /* DEBUG                                                                    */
381   /*--------------------------------------------------------------------------*/
382 #ifdef DUMP_LOG
383   chxj_dump_out("[src] CHTML->HDML", src, srclen);
384 #endif
385
386   /*--------------------------------------------------------------------------*/
387   /* It is examined whether there is a location header. It ends without doing */
388   /* anything when is.                                                        */
389   /*--------------------------------------------------------------------------*/
390   buf = (char *)apr_table_get(r->headers_out, (const char *)"Location");
391   if (buf) {
392     /*------------------------------------------------------------------------*/
393     /* The Location header generates tag in an initial HDML machine for the   */
394     /* uncorrespon dence.                                                     */
395     /*------------------------------------------------------------------------*/
396     DBG(r, "Location is not null[Location:%s]", buf);
397     s_output_to_hdml_out(&hdml, 
398         "<HDML VERSION=3.0 MARKABLE=TRUE PUBLIC=TRUE>\n"
399         "<NODISPLAY MARKABLE=TRUE PUBLIC=TRUE TITLE=\" \">\n"
400         "<ACTION TYPE=ACCEPT TASK=GO DEST=\""
401         );
402     s_output_to_hdml_out(&hdml, buf);
403     s_output_to_hdml_out(&hdml,
404         "\">\n"
405         "</NODISPLAY>\n"
406         "</HDML>\n"
407         );
408     dst = apr_pstrdup(r->pool, hdml.out);
409   }
410   else {
411     /*------------------------------------------------------------------------*/
412     /* Here, the parsing of the received character string is done             */
413     /*------------------------------------------------------------------------*/
414     // char *ss = apr_pstrdup(r->pool, src);
415     char *ss = apr_palloc(r->pool, srclen + 1);
416     memset(ss, 0, srclen + 1);
417     memcpy(ss, src, srclen);
418     
419     DBG(r, "input strlen(src)=[%d]\n", (int)srclen);
420     DBG(r, "[[[[%s]]]\n", src);
421
422     qs_init_malloc(&doc); 
423     qs_init_root_node(&doc);
424     ss[srclen] = '\0';
425     qs_parse_string(&doc, ss, srclen);
426
427     /*------------------------------------------------------------------------*/
428     /* The number of radiobuttons is counted.                                 */
429     /*------------------------------------------------------------------------*/
430     s_hdml_count_radio_tag(&hdml, qs_get_root(&doc));
431
432     chxj_node_convert(spec,r,(void*)&hdml, &doc, qs_get_root(&doc), 0);
433     dst = hdml.out;
434
435     DBG(r,"tmp=[%s]", dst);
436     qs_all_free(&doc,QX_LOGMARK);
437   }
438
439   /*--------------------------------------------------------------------------*/
440   /* DEBUG                                                                    */
441   /*--------------------------------------------------------------------------*/
442 #ifdef DUMP_LOG
443   chxj_dump_out("[dst] CHTML->HDML", hdml.out, hdml.out_len);
444 #endif
445
446   /*--------------------------------------------------------------------------*/
447   /* When there is no processing result, former character string is copied    */
448   /* and it returns it.                                                       */
449   /*--------------------------------------------------------------------------*/
450   if (!dst) {
451     *dstlen = srclen;
452     return apr_pstrdup(r->pool,src);
453   }
454
455   *dstlen = hdml.out_len;
456
457   /*--------------------------------------------------------------------------*/
458   /* Null is set at the end of the character string to make sure.             */
459   /*--------------------------------------------------------------------------*/
460   dst[hdml.out_len] = 0;
461
462   return dst;
463 }
464
465
466 /**
467  * The HDML structure is initialized. 
468  * 
469  * @param hdml [i/o] The pointer to the HDML structure that wants to be 
470  *                   initialized is specified. 
471  * @param doc  [i]   The Doc structure that should be set to the initialized 
472  *                   HDML structure is specified. 
473  * @param r    [i]   To use POOL, the pointer to request_rec is specified. 
474  * @param spec [i]   The pointer to the device_table
475  */
476 static void 
477 s_init_hdml(hdml_t *hdml, Doc *doc, request_rec *r, device_table *spec)
478 {
479   int     ii;
480   int     jj;
481
482   /*--------------------------------------------------------------------------*/
483   /* init hdml structure value                                                */
484   /*--------------------------------------------------------------------------*/
485   memset(hdml, 0, sizeof(hdml_t));
486   hdml->doc      = doc;
487   hdml->card     = qs_alloc_zero_byte_string(r);
488   hdml->spec     = spec;
489   hdml->conf     = ap_get_module_config(r->per_dir_config, &chxj_module);
490   hdml->doc->parse_mode = PARSE_MODE_CHTML;
491
492   for (ii=0; ii<MAX_FORM_COUNT; ii++) {
493     hdml->var_cnt[ii]     = 0;
494     hdml->postdata[ii]    = qs_alloc_zero_byte_string(r);
495   }
496
497   for (ii=0; ii<MAX_RADIO_COUNT; ii++) {
498     for (jj=0; jj<MAX_RADIO_VALUE_COUNT; jj++) 
499       hdml->radio_value_list[ii][jj] = NULL;
500
501     hdml->radio_name_list[ii]     = NULL;
502     hdml->radio_out_cnt[ii]       = 0;
503     hdml->radio_checked_value[ii] = NULL;
504   }
505
506   for (ii=0; ii<MAX_SUBMIT_BUTTON_COUNT; ii++) 
507     hdml->submit_button[ii] = NULL;
508
509   hdml->init_vars      = qs_alloc_zero_byte_string(r);
510
511   doc->r               = r;
512
513   hdml->form_cnt = apr_time_now();
514   hdml->out = qs_alloc_zero_byte_string(r);
515 }
516
517
518 /**
519  * It is a handler who processes the HTML tag. 
520  *
521  * @param pdoc   [i/o] The pointer to the HDML structure at the output
522  *                     destination is specified.
523  * @param node   [i]   The HTML tag node is specified. 
524  * @return The conversion result is returned. 
525  */
526 static char *
527 s_hdml_start_html_tag(void *pdoc, Node *UNUSED(node)) 
528 {
529   hdml_t *hdml;
530  
531   hdml = GET_HDML(pdoc);
532
533   s_output_to_hdml_out(hdml, 
534     "<HDML VERSION=3.0 TTL=0 MARKABLE=TRUE>\n"
535     "<NODISPLAY NAME=D0>\n"
536     "<ACTION TYPE=ACCEPT TASK=GOSUB DEST=#D1 NEXT=#D2 CLEAR=TRUE>\n"
537     "</NODISPLAY>\n"
538     );
539
540   hdml->card_cnt = 2;
541   hdml->hdml_br_flag = 0;
542
543   return hdml->out;
544 }
545
546
547 /**
548  * It is a handler who processes the HTML tag. 
549  *
550  * @param pdoc   [i/o] The pointer to the HDML structure at the output
551  *                     destination is specified.
552  * @param node   [i]   The HTML tag node is specified. 
553  * @return The conversion result is returned. 
554  */
555 static char *
556 s_hdml_end_html_tag(void *pdoc, Node *UNUSED(child)) 
557 {
558   hdml_t *hdml;
559
560   hdml = GET_HDML(pdoc);
561
562   s_output_to_hdml_card(hdml, 
563                   "<NODISPLAY NAME=D1>\n"
564                   "<ACTION TYPE=ACCEPT TASK=RETURN VARS=\""
565                   );
566
567   if (strlen(hdml->init_vars)) 
568     s_output_to_hdml_card(hdml, hdml->init_vars   );
569   else 
570     s_output_to_hdml_card(hdml, "_chxj_dmy="            );
571
572   s_output_to_hdml_card(hdml,   
573                   "\" CLEAR=TRUE>\n"
574                   "</NODISPLAY>\n"
575                   );
576
577   s_output_to_hdml_out(hdml, hdml->card );
578   s_output_to_hdml_out(hdml, "</HDML>\n");
579
580   hdml->hdml_end_flag = 1;
581
582   return hdml->out;
583 }
584
585
586 /**
587  * It is a handler who processes the META tag. 
588  *
589  * @param pdoc   [i/o] The pointer to the HDML structure at the output
590  *                     destination is specified.
591  * @param node   [i]   The META tag node is specified. 
592  * @return The conversion result is returned. 
593  */
594 static char *
595 s_hdml_start_meta_tag(void *pdoc, Node *UNUSED(node)) 
596 {
597   hdml_t *hdml;
598
599   hdml = GET_HDML(pdoc);
600
601   hdml->hdml_br_flag = 0;
602
603   /* ignore */
604
605   return hdml->out;
606 }
607
608
609 /**
610  * It is a handler who processes the META tag. 
611  *
612  * @param pdoc   [i/o] The pointer to the HDML structure at the output
613  *                     destination is specified.
614  * @param node   [i]   The META tag node is specified. 
615  * @return The conversion result is returned. 
616  */
617 static char *
618 s_hdml_end_meta_tag(void *pdoc, Node *UNUSED(child)) 
619 {
620   hdml_t *hdml;
621
622   hdml = GET_HDML(pdoc);
623
624   return hdml->out;
625 }
626
627
628 /**
629  * It is a handler who processes the HEAD tag. 
630  *
631  * @param pdoc   [i/o] The pointer to the HDML structure at the output
632  *                     destination is specified.
633  * @param node   [i]   The HEAD tag node is specified. 
634  * @return The conversion result is returned. 
635  */
636 static char *
637 s_hdml_start_head_tag(void *pdoc, Node *UNUSED(node)) 
638 {
639   hdml_t *hdml;
640
641   hdml = GET_HDML(pdoc);
642
643   /* ignore */
644
645   hdml->hdml_br_flag = 0;
646
647   return hdml->out;
648 }
649
650
651 /**
652  * It is a handler who processes the HEAD tag. 
653  *
654  * @param pdoc   [i/o] The pointer to the HDML structure at the output
655  *                     destination is specified.
656  * @param node   [i]   The HEAD tag node is specified. 
657  * @return The conversion result is returned. 
658  */
659 static char *
660 s_hdml_end_head_tag(void *pdoc, Node *UNUSED(child)) 
661 {
662   hdml_t *hdml;
663
664   hdml = GET_HDML(pdoc);
665   /* ignore */
666
667   return hdml->out;
668 }
669
670
671 /**
672  * It is a handler who processes the TITLE tag. 
673  *
674  * @param pdoc   [i/o] The pointer to the HDML structure at the output
675  *                     destination is specified.
676  * @param node   [i]   The TITLE tag node is specified. 
677  * @return The conversion result is returned. 
678  */
679 static char *
680 s_hdml_start_title_tag(void *pdoc, Node *UNUSED(node)) 
681 {
682   hdml_t *hdml;
683
684   hdml = GET_HDML(pdoc);
685
686   s_output_to_hdml_out(hdml, "<DISPLAY NAME=D2 TITLE=\"");
687
688   hdml->found_title = 1;
689   hdml->hdml_br_flag = 0;
690
691   return hdml->out;
692 }
693
694
695 /**
696  * It is a handler who processes the TITLE tag. 
697  *
698  * @param pdoc   [i/o] The pointer to the HDML structure at the output
699  *                     destination is specified.
700  * @param node   [i]   The TITLE tag node is specified. 
701  * @return The conversion result is returned. 
702  */
703 static char *
704 s_hdml_end_title_tag(void *pdoc, Node *UNUSED(child)) 
705 {
706   hdml_t *hdml;
707
708   hdml = GET_HDML(pdoc);
709
710   s_output_to_hdml_out(hdml, "\">\n");
711
712   return hdml->out;
713 }
714
715
716 /**
717  * It is a handler who processes the BASE tag. 
718  *
719  * @param pdoc   [i/o] The pointer to the HDML structure at the output
720  *                     destination is specified.
721  * @param node   [i]   The BASE tag node is specified. 
722  * @return The conversion result is returned. 
723  */
724 static char *
725 s_hdml_start_base_tag(void *pdoc, Node *UNUSED(node)) 
726 {
727   hdml_t *hdml;
728
729   hdml = GET_HDML(pdoc);
730
731   hdml->hdml_br_flag = 0;
732
733   return hdml->out;
734 }
735
736
737 /**
738  * It is a handler who processes the BASE tag. 
739  *
740  * @param pdoc   [i/o] The pointer to the HDML structure at the output
741  *                     destination is specified.
742  * @param node   [i]   The BASE tag node is specified. 
743  * @return The conversion result is returned. 
744  */
745 static char *
746 s_hdml_end_base_tag(void *pdoc, Node *UNUSED(child)) 
747 {
748   hdml_t *hdml;
749
750   hdml = GET_HDML(pdoc);
751
752   return hdml->out;
753 }
754
755
756 /**
757  * It is a handler who processes the BODY tag. 
758  *
759  * @param pdoc   [i/o] The pointer to the HDML structure at the output
760  *                     destination is specified.
761  * @param node   [i]   The BODY tag node is specified. 
762  * @return The conversion result is returned. 
763  */
764 static char *
765 s_hdml_start_body_tag(void *pdoc, Node *node) 
766 {
767   hdml_t       *hdml;
768   Doc          *doc;
769   Attr         *attr;
770
771   hdml = GET_HDML(pdoc);
772
773   doc  = hdml->doc;
774
775   if (hdml->found_title == 0)
776     s_output_to_hdml_out(hdml, "<DISPLAY NAME=D2 TITLE=\"NO TITLE\">\n");
777
778   s_output_to_hdml_out(hdml, "<ACTION TYPE=ACCEPT TASK=NOOP LABEL=\" \"");
779
780   /*--------------------------------*/
781   /* Get Attributes                 */
782   /*--------------------------------*/
783   for (attr = qs_get_attr(doc,node); 
784     attr; 
785     attr = qs_get_next_attr(doc,attr)) {
786
787     char *name;
788
789     name  = qs_get_attr_name(doc,attr);
790
791     if ((*name == 'b' || *name == 'B') && strcasecmp(name, "bgcolor")     == 0) {
792       /* ignore */
793     }
794     else 
795     if ((*name == 't' || *name == 'T') && strcasecmp(name, "text")   == 0) {
796       /* ignore */
797     }
798     else 
799     if ((*name == 'l' || *name == 'L') && strcasecmp(name, "link")   == 0) {
800       /* ignore */
801     }
802     else 
803     if ((*name == 'a' || *name == 'A') && strcasecmp(name, "alink")  == 0) {
804       /* ignore */
805     }
806     else 
807     if ((*name == 'v' || *name == 'V') && strcasecmp(name, "vlink")  == 0) {
808       /* ignore */
809     }
810   }
811
812   s_output_to_hdml_out(hdml, ">\n");
813
814   hdml->hdml_br_flag = 0;
815
816   return hdml->out;
817 }
818
819
820 /**
821  * It is a handler who processes the BODY tag. 
822  *
823  * @param pdoc   [i/o] The pointer to the HDML structure at the output
824  *                     destination is specified.
825  * @param node   [i]   The BODY tag node is specified. 
826  * @return The conversion result is returned. 
827  */
828 static char *
829 s_hdml_end_body_tag(void *pdoc, Node *UNUSED(child)) 
830 {
831   hdml_t *hdml;
832
833   hdml = GET_HDML(pdoc);
834
835   s_output_to_hdml_out(hdml, "\n</DISPLAY>\n");
836
837   return hdml->out;
838 }
839
840
841 /**
842  * It is a handler who processes the A tag. 
843  *
844  * @param pdoc   [i/o] The pointer to the HDML structure at the output
845  *                     destination is specified.
846  * @param node   [i]   The A tag node is specified. 
847  * @return The conversion result is returned. 
848  */
849 static char *
850 s_hdml_start_a_tag(void *pdoc, Node *node) 
851 {
852   hdml_t       *hdml;
853   Doc          *doc;
854   Attr         *attr;
855
856   hdml = GET_HDML(pdoc);
857   doc  = hdml->doc;
858
859   s_hdml_tag_output_upper_half(hdml,node);
860
861   s_output_to_hdml_out(hdml, "<A");
862
863
864   /*------------------------------------*/
865   /* Get Attributes                     */
866   /*------------------------------------*/
867   for (attr = qs_get_attr(doc,node);
868        attr;
869        attr = qs_get_next_attr(doc,attr)) {
870
871     char *name;
872     char *value;
873
874     name  = qs_get_attr_name(doc,attr);
875     value = qs_get_attr_value(doc,attr);
876
877     if ((*name == 'n' || *name == 'N') && strcasecmp(name, "name") == 0) {
878       /* IGNORE */
879     }
880     else 
881     if ((*name == 'h' || *name == 'H') && strcasecmp(name, "href") == 0) {
882       if ((*value == 'm' || *value == 'M') 
883       && strncasecmp(value, "mailto:", 7) == 0) {
884         value = chxj_encoding_parameter(hdml->doc->r, value);
885         s_output_to_hdml_out(hdml, " TASK=GO DEST=\""     );
886         s_output_to_hdml_out(hdml, value                  );
887         s_output_to_hdml_out(hdml, "\" "                  );
888       }
889       else 
890       if ((*value == 't' || *value == 'T') 
891       && strncasecmp(value, "tel:", 4) == 0) {
892
893         s_output_to_hdml_out(hdml,  " TASK=CALL NUMBER=\"");
894         s_output_to_hdml_out(hdml, &value[4]              );
895         s_output_to_hdml_out(hdml, "\" "                  );
896       }
897       else {
898         s_output_to_hdml_out(hdml, " TASK=GO DEST=\""     );
899         s_output_to_hdml_out(hdml, value                  );
900         s_output_to_hdml_out(hdml, "\""                   );
901       }
902     }
903     else
904     if ((*name == 'a' || *name == 'A') && strcasecmp(name, "accesskey") == 0) {
905       if (strcasecmp(value, "0") != 0) {
906         s_output_to_hdml_out(hdml, " ACCESSKEY="          );
907         s_output_to_hdml_out(hdml, value                  );
908         s_output_to_hdml_out(hdml, ""                     );
909       }
910     }
911     else
912     if ((*name == 'c' || *name == 'C') && strcasecmp(name, "cti") == 0) {
913       /* ignore */
914     }
915     else
916     if ((*name == 'i' || *name == 'I') && strcasecmp(name, "ijam") == 0) {
917       /* ignore */
918     }
919     else
920     if ((*name == 'u' || *name == 'U') && strcasecmp(name, "utn") == 0) {
921       /* ignore */
922     }
923     else
924     if ((*name == 't' || *name == 'T') && strcasecmp(name, "telbook") == 0) {
925       /* ignore */
926     }
927     else
928     if ((*name == 'k' || *name == 'K') && strcasecmp(name, "kana") == 0) {
929       /* ignore */
930     }
931     else
932     if ((*name == 'e' || *name == 'E') && strcasecmp(name, "email") == 0) {
933       /* ignore */
934     }
935     else
936     if ((*name == 'i' || *name == 'I') && strcasecmp(name, "ista") == 0) {
937       /* ignore */
938     }
939     else
940     if ((*name == 'i' || *name == 'I') && strcasecmp(name, "ilet") == 0) {
941       /* ignore */
942     }
943     else
944     if ((*name == 'i' || *name == 'I') && strcasecmp(name, "iswf") == 0) {
945       /* ignore */
946     }
947     else
948     if ((*name == 'i' || *name == 'I') && strcasecmp(name, "irst") == 0) {
949       /* ignore */
950     }
951   }
952   s_output_to_hdml_out(hdml, ">"  );
953
954   hdml->hdml_a_flag = 1;
955
956   hdml->hdml_br_flag = 0;
957
958   return hdml->out;
959 }
960
961
962 /**
963  * It is a handler who processes the A tag. 
964  *
965  * @param pdoc   [i/o] The pointer to the HDML structure at the output
966  *                     destination is specified.
967  * @param node   [i]   The A tag node is specified. 
968  * @return The conversion result is returned. 
969  */
970 static char *
971 s_hdml_end_a_tag(void *pdoc, Node *UNUSED(child)) 
972 {
973   hdml_t *hdml;
974
975   hdml = GET_HDML(pdoc);
976
977   s_output_to_hdml_out(hdml, "</A>\n");
978
979   hdml->hdml_a_flag = 0;
980
981   return hdml->out;
982 }
983
984
985 /**
986  * It is a handler who processes the BR tag. 
987  *
988  * @param pdoc   [i/o] The pointer to the HDML structure at the output
989  *                     destination is specified.
990  * @param node   [i]   The BR tag node is specified. 
991  * @return The conversion result is returned. 
992  */
993 static char *
994 s_hdml_start_br_tag(void *pdoc, Node *UNUSED(node)) 
995 {
996   hdml_t *hdml;
997
998   hdml = GET_HDML(pdoc);
999
1000   if (hdml->in_center > 0) 
1001     hdml->in_center = 0;
1002
1003   if (hdml->div_in_center > 0) 
1004     hdml->div_in_center = 0;
1005
1006   s_output_to_hdml_out(hdml, "<BR>\n");
1007
1008   hdml->hdml_br_flag = 1;
1009
1010   return hdml->out;
1011 }
1012
1013
1014 /**
1015  * It is a handler who processes the BR tag. 
1016  *
1017  * @param pdoc   [i/o] The pointer to the HDML structure at the output
1018  *                     destination is specified.
1019  * @param node   [i]   The BR tag node is specified. 
1020  * @return The conversion result is returned. 
1021  */
1022 static char *
1023 s_hdml_end_br_tag(void *pdoc, Node *UNUSED(child)) 
1024 {
1025   hdml_t *hdml;
1026
1027   hdml = GET_HDML(pdoc);
1028
1029   return hdml->out;
1030 }
1031
1032
1033 /**
1034  * It is a handler who processes the TR tag. 
1035  *
1036  * @param pdoc   [i/o] The pointer to the HDML structure at the output
1037  *                     destination is specified.
1038  * @param node   [i]   The TR tag node is specified. 
1039  * @return The conversion result is returned. 
1040  */
1041 static char *
1042 s_hdml_start_tr_tag(void *pdoc, Node *UNUSED(node)) 
1043 {
1044   hdml_t *hdml;
1045
1046   hdml = GET_HDML(pdoc);
1047
1048   if (hdml->in_center > 0) 
1049     hdml->in_center = 0;
1050
1051   if (hdml->div_in_center > 0) 
1052     hdml->div_in_center = 0;
1053
1054   s_output_to_hdml_out(hdml, "<BR>\n");
1055
1056   hdml->hdml_br_flag = 1;
1057
1058   return hdml->out;
1059 }
1060
1061
1062 /**
1063  * It is a handler who processes the TR tag. 
1064  *
1065  * @param pdoc   [i/o] The pointer to the HDML structure at the output
1066  *                     destination is specified.
1067  * @param node   [i]   The TR tag node is specified. 
1068  * @return The conversion result is returned. 
1069  */
1070 static char *
1071 s_hdml_end_tr_tag(void *pdoc, Node *UNUSED(child)) 
1072 {
1073   hdml_t *hdml;
1074
1075   hdml = GET_HDML(pdoc);
1076
1077   return hdml->out;
1078 }
1079
1080
1081 /**
1082  * It is a handler who processes the FONT tag. 
1083  *
1084  * @param pdoc   [i/o] The pointer to the HDML structure at the output
1085  *                     destination is specified.
1086  * @param node   [i]   The FONT tag node is specified. 
1087  * @return The conversion result is returned. 
1088  */
1089 static char *
1090 s_hdml_start_font_tag(void *pdoc, Node *UNUSED(node)) 
1091 {
1092   hdml_t *hdml;
1093
1094   hdml = GET_HDML(pdoc);
1095
1096   return hdml->out;
1097 }
1098
1099
1100 /**
1101  * It is a handler who processes the FONT tag. 
1102  *
1103  * @param pdoc   [i/o] The pointer to the HDML structure at the output
1104  *                     destination is specified.
1105  * @param node   [i]   The FONT tag node is specified. 
1106  * @return The conversion result is returned. 
1107  */
1108 static char *
1109 s_hdml_end_font_tag(void *pdoc, Node *UNUSED(child)) 
1110 {
1111   hdml_t *hdml;
1112
1113   hdml = GET_HDML(pdoc);
1114
1115   return hdml->out;
1116 }
1117
1118
1119 /**
1120  * It is a handler who processes the FORM tag. 
1121  *
1122  * @param pdoc   [i/o] The pointer to the HDML structure at the output
1123  *                     destination is specified.
1124  * @param node   [i]   The FORM tag node is specified. 
1125  * @return The conversion result is returned. 
1126  */
1127 static char *
1128 s_hdml_start_form_tag(void *pdoc, Node *node) 
1129 {
1130   hdml_t       *hdml;
1131   request_rec  *r;
1132   Attr         *attr;
1133   Doc          *doc;
1134   char         *act;
1135
1136   hdml = GET_HDML(pdoc);
1137   doc  = hdml->doc;
1138   r    = hdml->doc->r;
1139   act  = NULL;
1140
1141   hdml->form_tmp = apr_psprintf(r->pool,
1142                   "<NODISPLAY NAME=F%d>\n",
1143                   hdml->pure_form_cnt);
1144   hdml->form_tmp = apr_pstrcat(r->pool,
1145                               hdml->form_tmp,
1146                              "<ACTION TYPE=ACCEPT TASK=GO METHOD=POST DEST=\"",
1147                               NULL);
1148   /* Get Attributes */
1149   for (attr = qs_get_attr(doc,node); 
1150        attr; 
1151        attr = qs_get_next_attr(doc,attr)) {
1152
1153     char *name;
1154     char *value;
1155
1156     name  = qs_get_attr_name(doc,attr);
1157     value = qs_get_attr_value(doc,attr);
1158
1159     if ((*name == 'a' || *name == 'A') && strcasecmp(name, "action") == 0) {
1160       value = chxj_encoding_parameter(hdml->doc->r, value);
1161       act = apr_psprintf(r->pool, "%s", value);
1162       break;
1163     }
1164   }
1165
1166   if (act) {
1167     hdml->form_tmp = apr_pstrcat(r->pool,
1168                                  hdml->form_tmp,
1169                                  act,
1170                                  NULL);
1171   }
1172   hdml->form_tmp = apr_pstrcat(r->pool,
1173                                hdml->form_tmp,
1174                                "\" ",
1175                                NULL);
1176   hdml->form_tmp = apr_pstrcat(r->pool,
1177                                hdml->form_tmp,
1178                                "POSTDATA=\"", 
1179                                NULL);
1180
1181   hdml->hdml_br_flag = 0;
1182
1183   return hdml->out;
1184 }
1185
1186
1187 /**
1188  * handler of the form end tag. 
1189  *
1190  * @param pdoc [i/o] The pointer to the HDML structure at the output
1191  *                   destination is specified.
1192  * @param child [i]  unused.
1193  * @return The HDML output result after it edits it is returned. 
1194  */
1195 static char *
1196 s_hdml_end_form_tag(void *pdoc, Node *UNUSED(child)) 
1197 {
1198   hdml_t       *hdml;
1199   request_rec  *r;
1200
1201   hdml = GET_HDML(pdoc);
1202   r    = hdml->doc->r;
1203
1204   s_output_to_postdata(hdml, "_chxj_dmy=");
1205
1206   hdml->form_tmp = apr_pstrcat(r->pool, 
1207                                hdml->form_tmp,
1208                                hdml->postdata[hdml->pure_form_cnt],
1209                                NULL);
1210
1211   hdml->form_tmp = apr_pstrcat(r->pool,
1212                                hdml->form_tmp,
1213                                "\" CLEAR=TRUE >\n", 
1214                                NULL);
1215   hdml->form_tmp = apr_pstrcat(r->pool,
1216                                hdml->form_tmp,
1217                                "</NODISPLAY>\n",
1218                                NULL);
1219
1220   s_output_to_hdml_card(hdml, hdml->form_tmp);
1221
1222   hdml->form_tmp = NULL;
1223   hdml->pure_form_cnt++;
1224
1225   return hdml->out;
1226 }
1227
1228
1229 /**
1230  * It is a handler that takes charge of the processing of the input tag. 
1231  *
1232  * @param pdoc [i/o] The pointer to the HDML structure at the output
1233  *                   destination is specified.
1234  * @param node [i]   The tag node to be processed is specified. 
1235  */
1236 static char *
1237 s_hdml_start_input_tag(void *pdoc, Node *node) 
1238 {
1239   hdml_t     *hdml;
1240   Doc        *doc;
1241   Attr       *attr;
1242
1243   hdml = GET_HDML(pdoc);
1244   doc  = hdml->doc;
1245
1246   /*--------------------------------------------------------------------------*/
1247   /* The attribute of the input tag is acquired.                              */
1248   /*--------------------------------------------------------------------------*/
1249   for (attr = qs_get_attr(doc,node); 
1250        attr; 
1251        attr = qs_get_next_attr(doc,attr)) {
1252
1253     char *name;
1254     char *value;
1255
1256     name  = qs_get_attr_name(doc,attr);
1257     value = qs_get_attr_value(doc,attr);
1258
1259     if ((*name == 't'|| *name == 'T') && strcasecmp(name, "type") == 0) {
1260       if ((*value == 't' || *value == 'T') && strcasecmp(value, "text") == 0) {
1261         /*--------------------------------------------------------------------*/
1262         /* "input type ='text'" tag is processed.                             */
1263         /*--------------------------------------------------------------------*/
1264         s_hdml_do_input_text_tag(hdml, node);
1265       }
1266       else
1267       if ((*value == 'p' || *value == 'P') && strcasecmp(value, "password") == 0) {
1268         /*--------------------------------------------------------------------*/
1269         /* "input type='password'" tag is processed.                          */
1270         /*--------------------------------------------------------------------*/
1271         s_hdml_do_input_password_tag(hdml, node);
1272       }
1273       else
1274       if ((*value == 's' || *value == 'S') && strcasecmp(value, "submit") == 0) {
1275         /*--------------------------------------------------------------------*/
1276         /* "input type='submit'" tag is processed.                            */
1277         /*--------------------------------------------------------------------*/
1278         s_hdml_do_input_submit_tag(hdml, node);
1279       }
1280       else 
1281       if ((*value == 'h' || *value == 'H') && strcasecmp(value, "hidden") == 0) {
1282         /*--------------------------------------------------------------------*/
1283         /* "input type='hidden'" tag is processed.                            */
1284         /*--------------------------------------------------------------------*/
1285         s_hdml_do_input_hidden_tag(hdml, node);
1286       }
1287       else
1288       if ((*value == 'r' || *value == 'R') && strcasecmp(value, "radio") == 0) {
1289         /*--------------------------------------------------------------------*/
1290         /* "input type='radio'" tag is processed.                             */
1291         /*--------------------------------------------------------------------*/
1292         s_hdml_do_input_radio_tag(hdml, node);
1293       }
1294       else 
1295       if ((*value == 'c' || *value == 'C') && strcasecmp(value, "checkbox") == 0) {
1296         /*--------------------------------------------------------------------*/
1297         /* "input type='checkbox'" tag is processed.                          */
1298         /*--------------------------------------------------------------------*/
1299         s_hdml_do_input_checkbox_tag(hdml, node);
1300       }
1301     }
1302     else 
1303     if ((*name == 'n' || *name == 'N') && strcasecmp(name, "name")      == 0) {
1304       /* ignore */
1305     }
1306     else
1307     if ((*name == 'v' || *name == 'V') && strcasecmp(name, "value")     == 0) {
1308       /* ignore */
1309     }
1310     else
1311     if ((*name == 's' || *name == 'S') && strcasecmp(name, "size")      == 0) {
1312       /* ignore */
1313     }
1314     else
1315     if ((*name == 'm' || *name == 'M') && strcasecmp(name, "maxlength") == 0) {
1316       /* ignore */
1317     }
1318     else
1319     if ((*name == 'c' || *name == 'C') && strcasecmp(name, "checked")   == 0) {
1320       /* ignore */
1321     }
1322     else 
1323     if ((*name == 'a' || *name == 'A') && strcasecmp(name, "accesskey") == 0) {
1324       /* ignore */
1325     }
1326     else
1327     if ((*name == 'i' || *name == 'I') && strcasecmp(name, "istyle")    == 0) {
1328       /* ignore */
1329     }
1330   }
1331
1332   hdml->hdml_br_flag = 0;
1333
1334   return hdml->out;
1335 }
1336
1337
1338 /**
1339  * The substitution processing of tag "input type = text" is done. 
1340  * 
1341  * @param hdml [i/o] The pointer to the HDML structure at the output 
1342  *                   destination is specified. 
1343  * @param tag  [i]   The tag node of input type=text is specified. 
1344  */
1345 static void
1346 s_hdml_do_input_text_tag(hdml_t *hdml, Node *tag)
1347 {
1348   Doc           *doc;
1349   request_rec   *r;
1350   char          *mlen;
1351   char          *val;
1352   char          *is;
1353   char          *nm;
1354   char          *fmt;
1355   size_t        ii;
1356
1357   doc   = hdml->doc;
1358   r     = doc->r;
1359
1360   s_hdml_tag_output_upper_half(hdml, tag);
1361
1362   hdml->card_cnt++;
1363   s_output_to_hdml_out(hdml, 
1364                        apr_psprintf(r->pool,
1365                                     "<A TASK=GOSUB LABEL=\x93\xfc\x97\xcd DEST=#D%d "
1366                                     "VARS=\"V=$%s%02d\" RECEIVE=%s%02d>",
1367                                     hdml->card_cnt,
1368                                     s_get_form_no(r, hdml),
1369                                     hdml->var_cnt[hdml->pure_form_cnt],
1370                                     s_get_form_no(r, hdml),
1371                                     hdml->var_cnt[hdml->pure_form_cnt]
1372                       ));
1373
1374   s_output_to_hdml_out(hdml, 
1375                        apr_psprintf(r->pool, 
1376                                     "[$%s%02d]</A>\n"  , 
1377                                     s_get_form_no(r, hdml),
1378                           hdml->var_cnt[hdml->pure_form_cnt]));
1379
1380   /*--------------------------------------------------------------------------*/
1381   /* ENTRY CARD is output here.                                               */
1382   /*--------------------------------------------------------------------------*/
1383   s_output_to_hdml_card(hdml, "<ENTRY NAME="                               );
1384   s_output_to_hdml_card(hdml, apr_psprintf(r->pool, "D%d ", hdml->card_cnt));
1385   s_output_to_hdml_card(hdml, " KEY=V DEFAULT=$V "                         );
1386
1387   mlen = NULL;
1388   is   = NULL;
1389   val  = NULL;
1390   fmt  = NULL;
1391   nm = qs_get_name_attr(doc, tag, r);
1392   if (! nm) {
1393     nm = qs_alloc_zero_byte_string(r);
1394   }
1395
1396   s_output_to_postdata(hdml, 
1397                        apr_psprintf(r->pool, 
1398                                     "%s=$%s%02d", 
1399                                     nm,
1400                                     s_get_form_no(r, hdml),
1401                                     hdml->var_cnt[hdml->pure_form_cnt]));
1402
1403   mlen = qs_get_maxlength_attr  (doc, tag, r);
1404   is   = qs_get_istyle_attr     (doc, tag, r);
1405   val  = qs_get_value_attr      (doc, tag, r);
1406
1407   fmt  = qs_conv_istyle_to_format(r, is);
1408   DBG(r,"qs_conv_istyle_to_format end");
1409         
1410   if (fmt) {
1411     if (mlen) {
1412       for (ii=0; ii<strlen(mlen); ii++) {
1413         if (mlen[ii] < '0' || mlen[ii] > '9') {
1414           mlen = apr_psprintf(r->pool, "0");
1415           break;
1416         }
1417       }
1418       s_output_to_hdml_card(hdml, apr_psprintf(r->pool, " FORMAT=%d%s", atoi(mlen), fmt));
1419     }
1420     else 
1421       s_output_to_hdml_card(hdml, apr_psprintf(r->pool, " FORMAT=*%s", fmt)       );
1422   }
1423
1424   s_output_to_hdml_card(hdml, 
1425                         " MARKABLE=FALSE>\n"
1426                         "<ACTION TYPE=ACCEPT TASK=RETURN RETVALS=$V>\n"
1427                         "</ENTRY>\n");
1428
1429   if (val) 
1430     s_output_to_init_vars(hdml, 
1431                           apr_psprintf(r->pool, 
1432                                        "%s%02d=%s", 
1433                                        s_get_form_no(r, hdml),
1434                                        hdml->var_cnt[hdml->pure_form_cnt],
1435                                        ap_escape_uri(r->pool,val)));
1436   else 
1437     s_output_to_init_vars(hdml, 
1438                           apr_psprintf(r->pool, 
1439                                        "%s%02d=", 
1440                                        s_get_form_no(r, hdml),
1441                                        hdml->var_cnt[hdml->pure_form_cnt]));
1442
1443   hdml->var_cnt[hdml->pure_form_cnt]++;
1444 }
1445
1446
1447 /**
1448  * The substitution processing of tag "input type = password" is done. 
1449  * 
1450  * @param hdml [i/o] The pointer to the HDML structure at the output 
1451  *                   destination is specified. 
1452  * @param tag  [i]   The tag node of input type=password is specified. 
1453  */
1454 static void
1455 s_hdml_do_input_password_tag(hdml_t *hdml, Node *tag)
1456 {
1457   Doc             *doc;
1458   request_rec     *r;
1459   char            *mlen;
1460   char            *val;
1461   char            *is;
1462   char            *nm;
1463   char            *fmt;
1464
1465   doc = hdml->doc;
1466   r   = doc->r;
1467
1468   s_hdml_tag_output_upper_half(hdml, tag);
1469
1470   hdml->card_cnt++;
1471   s_output_to_hdml_out(hdml, "<A TASK=GOSUB LABEL=\"\x93\xfc\x97\xcd\" DEST=");
1472   s_output_to_hdml_out(hdml, apr_psprintf(r->pool, "#D%d ", hdml->card_cnt));
1473   s_output_to_hdml_out(hdml, 
1474                        apr_psprintf(r->pool, 
1475                                     "VARS=\"V=$%s%02d\" ", 
1476                                     s_get_form_no(r, hdml),
1477                                     hdml->var_cnt[hdml->pure_form_cnt]));
1478
1479   s_output_to_hdml_out(hdml, 
1480                   apr_psprintf(r->pool, "RECEIVE=%s%02d>"  , 
1481                                s_get_form_no(r, hdml),
1482                           hdml->var_cnt[hdml->pure_form_cnt]));
1483   s_output_to_hdml_out(hdml, 
1484                   apr_psprintf(r->pool, "[$%s%02d]</A>\n"  , 
1485                           s_get_form_no(r, hdml),
1486                           hdml->var_cnt[hdml->pure_form_cnt]));
1487
1488   s_output_to_hdml_card(hdml, "<ENTRY NAME="                               );
1489   s_output_to_hdml_card(hdml, apr_psprintf(r->pool, "D%d ", hdml->card_cnt));
1490   s_output_to_hdml_card(hdml, " KEY=V DEFAULT=$V "                         );
1491
1492   mlen = NULL;
1493   is   = NULL;
1494   val  = NULL;
1495   fmt  = NULL;
1496
1497   nm = qs_get_name_attr(doc, tag, r);
1498   if (! nm)
1499     nm = qs_alloc_zero_byte_string(r);
1500
1501   s_output_to_postdata(hdml, 
1502                   apr_psprintf(r->pool, 
1503                           "%s=$%s%02d", 
1504                           nm,
1505                           s_get_form_no(r, hdml),
1506                           hdml->var_cnt[hdml->pure_form_cnt]));
1507
1508   mlen = qs_get_maxlength_attr  (doc, tag, r);
1509   val  = qs_get_value_attr      (doc, tag, r);
1510   /*--------------------------------------------------------------------------*/
1511   /* Default is a figure input.                                               */
1512   /*--------------------------------------------------------------------------*/
1513   fmt = apr_psprintf(r->pool, "N");
1514   if (mlen) {
1515     if (chxj_chk_numeric(mlen) != 0)
1516       mlen = apr_psprintf(r->pool, "0");
1517     s_output_to_hdml_card(hdml, 
1518                     apr_psprintf(r->pool, " FORMAT=%d%s", chxj_atoi(mlen), fmt));
1519   }
1520   else 
1521     s_output_to_hdml_card(hdml, 
1522                     apr_psprintf(r->pool, " FORMAT=*%s", fmt)       );
1523
1524   s_output_to_hdml_card(hdml, apr_psprintf(r->pool, " NOECHO=TRUE "));
1525
1526   s_output_to_hdml_card(hdml, 
1527                   " MARKABLE=FALSE>\n"
1528                   "<ACTION TYPE=ACCEPT TASK=RETURN RETVALS=$V>\n"
1529                   "</ENTRY>\n");
1530
1531   if (val) 
1532     s_output_to_init_vars(hdml, 
1533                     apr_psprintf(r->pool, "%s%02d=%s", 
1534                         s_get_form_no(r, hdml),
1535                         hdml->var_cnt[hdml->pure_form_cnt], 
1536                         ap_escape_uri(r->pool,val)));
1537   else 
1538     s_output_to_init_vars(hdml, 
1539                     apr_psprintf(r->pool, "%s%02d=", 
1540                         s_get_form_no(r, hdml),
1541                         hdml->var_cnt[hdml->pure_form_cnt]));
1542
1543   hdml->var_cnt[hdml->pure_form_cnt]++;
1544 }
1545
1546 /**
1547  * The substitution processing of tag "input type = submit" is done. 
1548  * 
1549  * @param hdml [i/o] The pointer to the HDML structure at the output 
1550  *                   destination is specified. 
1551  * @param tag  [i]   The tag node of input type=submit is specified. 
1552  */
1553 static void
1554 s_hdml_do_input_submit_tag(hdml_t *hdml, Node *tag)
1555 {
1556   Doc           *doc = hdml->doc;
1557   request_rec   *r   = doc->r;
1558   char          *nm  = NULL;
1559   char          *val = NULL;
1560
1561   s_hdml_tag_output_upper_half(hdml, tag);
1562
1563   s_output_to_hdml_out(hdml, 
1564                   apr_psprintf(r->pool, 
1565                           "<A TASK=GO LABEL=OK DEST=#F%d ",
1566                           hdml->pure_form_cnt));
1567
1568   /*--------------------------------------------------------------------------*/
1569   /* get name and value attribute                                             */
1570   /*--------------------------------------------------------------------------*/
1571   nm  = qs_get_name_attr  (doc, tag, r);
1572   val = qs_get_value_attr (doc, tag, r);
1573
1574   if (nm && val) {
1575     s_output_to_hdml_out(hdml, 
1576                     apr_psprintf(r->pool, "VARS=\"%s=%s\" ", 
1577                             nm, 
1578                             ap_escape_uri(r->pool,val)));
1579     if (strstr(hdml->postdata[hdml->pure_form_cnt], nm) == NULL) {
1580       s_output_to_postdata(hdml, 
1581                       apr_psprintf(r->pool,"%s%s=$%s", 
1582                               SUBMIT_BUTTON_PREFIX, nm, nm));
1583     }
1584   }
1585   s_output_to_hdml_out(hdml, ">"         );
1586   s_output_to_hdml_out(hdml, val);
1587   s_output_to_hdml_out(hdml, "</A>\n"    );
1588 }
1589
1590
1591 /**
1592  * The substitution processing of tag "input type = hidden" is done. 
1593  * 
1594  * @param hdml [i/o] The pointer to the HDML structure at the output 
1595  *                   destination is specified. 
1596  * @param tag  [i]   The tag node of input type=hidden is specified. 
1597  */
1598 static void
1599 s_hdml_do_input_hidden_tag(hdml_t *hdml, Node *tag)
1600 {
1601   Doc           *doc = hdml->doc;
1602   request_rec   *r   = doc->r;
1603   char          *nm  = NULL;
1604   char          *val = NULL;
1605
1606   /*--------------------------------------------------------------------------*/
1607   /* get name and value attribute                                             */
1608   /*--------------------------------------------------------------------------*/
1609   nm  = qs_get_name_attr  (doc, tag, r);
1610   val = qs_get_value_attr (doc, tag, r);
1611
1612   if (nm && val) {
1613     s_output_to_postdata(hdml, 
1614                     apr_psprintf(r->pool, 
1615                             "%s=%s", 
1616                             nm, 
1617                             ap_escape_uri(r->pool, val)));
1618   }
1619 }
1620
1621 /**
1622  * The substitution processing of tag "input type = radio" is done. 
1623  * 
1624  * @param hdml [i/o] The pointer to the HDML structure at the output 
1625  *                   destination is specified. 
1626  * @param tag  [i]   The tag node of input type=radio is specified. 
1627  */
1628 static void
1629 s_hdml_do_input_radio_tag(hdml_t *hdml, Node *tag)
1630 {
1631   Doc           *doc       = hdml->doc;
1632   request_rec   *r         = doc->r;
1633   char          *nm        = NULL;
1634   char          *val       = NULL;
1635   int           ii;
1636   int           jj;
1637   int           kk;
1638   int           r_cnt;
1639
1640   s_hdml_tag_output_upper_half(hdml, tag);
1641
1642   /*--------------------------------------------------------------------------*/
1643   /* get name and value attribute                                             */
1644   /*--------------------------------------------------------------------------*/
1645   nm  = qs_get_name_attr  (doc, tag, r);
1646   val = qs_get_value_attr (doc, tag, r);
1647
1648   /*--------------------------------------------------------------------------*/
1649   /* The same name is searched out from the list made beforehand.             */
1650   /*--------------------------------------------------------------------------*/
1651   for (ii=0; ii<MAX_RADIO_COUNT; ii++) {
1652     if (! hdml->radio_name_list[ii]) {
1653       /* @todo Oops..  */
1654       DBG(r, "Oops... radio list is null[%d]", ii);
1655       /*----------------------------------------------------------------------*/
1656       /* Processing is ended because it doesn't happen off the fly.           */
1657       /*----------------------------------------------------------------------*/
1658       return;
1659     }
1660
1661     if (strcasecmp(hdml->radio_name_list[ii], nm) == 0) 
1662       break;
1663   }
1664   if (ii == MAX_RADIO_COUNT) {
1665     /* @todo Oops.. */
1666     DBG(r,"Oops... The same name was not in the list. ");
1667     /*------------------------------------------------------------------------*/
1668     /* Processing is ended because it doesn't happen off the fly.             */
1669     /*------------------------------------------------------------------------*/
1670     return;
1671   }
1672
1673   s_output_to_hdml_out(hdml, 
1674                   apr_psprintf(r->pool, 
1675                           "<A TASK=GOSUB "
1676                           "LABEL=\"\x93\xfc\x97\xcd\" "
1677                           "DEST=#R%d VARS=\"VAL=%s\" "
1678                           "RECEIVE=\"%s;", 
1679                           ii, 
1680                           val, 
1681                           nm));
1682
1683   if (hdml->radio_out_cnt[ii] == 0) {
1684     s_output_to_hdml_card(hdml, 
1685                     apr_psprintf(r->pool,
1686                             "<NODISPLAY NAME=R%d>\n",
1687                             ii));
1688     s_output_to_hdml_card(hdml, 
1689                     apr_psprintf(r->pool, 
1690                             "<ACTION "
1691                             "TYPE=ACCEPT TASK=RETURN RETVALS=\"$VAL;"));
1692   }
1693
1694   kk = hdml->radio_out_cnt[ii];
1695   for (jj=0; jj<MAX_RADIO_VALUE_COUNT; jj++) 
1696     if (! hdml->radio_value_list[ii][jj]) 
1697       break;
1698
1699   r_cnt = jj;
1700
1701   for (jj=0; jj<r_cnt; jj++) {
1702     if (! hdml->radio_value_list[ii][jj])
1703       break;
1704
1705     if (jj != 0) {
1706       s_output_to_hdml_out(hdml, apr_psprintf(r->pool, ";"));
1707       if (hdml->radio_out_cnt[ii] == 0) 
1708         s_output_to_hdml_card(hdml, apr_psprintf(r->pool, ";"));
1709     }
1710
1711     s_output_to_hdml_out(hdml, apr_psprintf(r->pool, "%s_%02d", nm, kk));
1712     if (hdml->radio_out_cnt[ii] == 0)  {
1713       if (jj == 0) 
1714         s_output_to_hdml_card(hdml, apr_psprintf(r->pool, "X"));
1715       else 
1716         s_output_to_hdml_card(hdml, apr_psprintf(r->pool, "_"));
1717     }
1718
1719     kk++;
1720     if (kk >= r_cnt) 
1721       kk=0;
1722   }
1723   s_output_to_hdml_out(hdml, 
1724                   apr_psprintf(r->pool, "\" >$%s_%02d</A>", 
1725                           nm, 
1726                           hdml->radio_out_cnt[ii]));
1727   if (! hdml->radio_out_cnt[ii]) {
1728     s_output_to_hdml_card(hdml, "\">\n"         );
1729     s_output_to_hdml_card(hdml, "</NODISPLAY>\n");
1730
1731     s_output_to_postdata(hdml,  apr_psprintf(r->pool, "%s%s=$%s", RADIO_BUTTON_PREFIX, nm, nm));
1732
1733     for (jj=0; jj<r_cnt; jj++) {
1734       if (hdml->radio_value_list[ii][jj] &&  hdml->radio_checked_value[ii]) {
1735         if (strcasecmp(hdml->radio_value_list[ii][jj], 
1736                        hdml->radio_checked_value[ii]) == 0) {
1737           s_output_to_init_vars(hdml, 
1738                           apr_psprintf(r->pool, 
1739                                   "%s_%02d=X", 
1740                                   nm, 
1741                                   jj));
1742         }
1743         else {
1744           s_output_to_init_vars(hdml, 
1745                           apr_psprintf(r->pool, 
1746                                   "%s_%02d=_", 
1747                                   nm, 
1748                                   jj));
1749         }
1750       }
1751       else {
1752         s_output_to_init_vars(hdml, 
1753                         apr_psprintf(r->pool, 
1754                                 "%s_%02d=_", 
1755                                 nm, 
1756                                 jj));
1757       }
1758     }
1759
1760     if (hdml->radio_checked_value[ii]) {
1761       DBG(r,"radio button is checked. checked value is [%s]", 
1762         hdml->radio_checked_value[ii]);
1763       s_output_to_init_vars(hdml, 
1764                     apr_psprintf(r->pool, 
1765                             "%s=%s", 
1766                             nm, 
1767                             hdml->radio_checked_value[ii]));
1768     }
1769     else {
1770       DBG(r,"radio button is not checked. checked value is []");
1771       s_output_to_init_vars(hdml, 
1772                     apr_psprintf(r->pool, 
1773                             "%s=", 
1774                             nm));
1775     }
1776   }
1777   hdml->radio_out_cnt[ii]++;
1778 }
1779
1780
1781 /**
1782  * The substitution processing of tag "input type = checkbox" is done. 
1783  * 
1784  * @param hdml [i/o] The pointer to the HDML structure at the output 
1785  *                   destination is specified. 
1786  * @param tag  [i]   The tag node of input type=checkbox is specified. 
1787  */
1788 static void
1789 s_hdml_do_input_checkbox_tag(hdml_t *hdml, Node *tag)
1790 {
1791   Doc           *doc       = hdml->doc;
1792   request_rec   *r         = doc->r;
1793   char          *nm        = NULL;
1794   char          *val       = NULL;
1795   int           chk;
1796
1797   /*--------------------------------------------------------------------------*/
1798   /* It is posted to the one without the checked attribute.                   */
1799   /* However, they were able to be removed with INPUT FILTER.                 */
1800   /*--------------------------------------------------------------------------*/
1801   if (! hdml->has_checkbox) {
1802     hdml->has_checkbox++;
1803     s_output_to_hdml_card(hdml, 
1804                     "<NODISPLAY NAME=\"_chk\">\n"
1805                     "<ACTION TYPE=\"ACCEPT\" TASK=\"RETURN\" "
1806                                              "RETVALS=\"_uchk;$V;X\" >\n"
1807                     "</NODISPLAY>\n"
1808                     "<NODISPLAY NAME=\"_uchk\">\n"
1809                     "<ACTION TYPE=\"ACCEPT\" TASK=\"RETURN\" "
1810                                              "RETVALS=\"_chk;;_\" >\n"
1811                     "</NODISPLAY>\n"
1812                     );
1813     DBG(r, "wrote checkbox hdml card.");
1814   }
1815         
1816   /*--------------------------------------------------------------------------*/
1817   /* It is examined whether it is CHECKED.                                    */
1818   /*--------------------------------------------------------------------------*/
1819   chk = qs_is_checked_checkbox_attr(doc, tag, r);
1820
1821   /*--------------------------------------------------------------------------*/
1822   /* The value of the name attribute and the value attribute is acquired      */
1823   /* respectively.                                                            */
1824   /*--------------------------------------------------------------------------*/
1825   val = qs_get_value_attr(doc, tag, r);
1826   nm  = qs_get_name_attr(doc, tag, r);
1827
1828   if (! val) 
1829     val    = qs_alloc_zero_byte_string(r);
1830
1831   if (! nm)
1832     nm   = qs_alloc_zero_byte_string(r);
1833
1834   s_output_to_hdml_out(hdml, apr_psprintf(r->pool, 
1835                                 "<A TASK=GOSUB LABEL=\"a\xaf\xb8\" "
1836                                    "DEST=\"#$%s%02d\" "
1837                                    "VARS=\"V=%s\" "
1838                                    "RECEIVE=\"%s%02d;%s%02d;%s%02d\">"
1839                                    "$%s%02d</A>\n",
1840                                 s_get_form_no(r, hdml),
1841                                 hdml->var_cnt[hdml->pure_form_cnt] + 0,
1842                                 val,
1843                                 s_get_form_no(r, hdml),
1844                                 hdml->var_cnt[hdml->pure_form_cnt] + 0,
1845                                 s_get_form_no(r, hdml),
1846                                 hdml->var_cnt[hdml->pure_form_cnt] + 1,
1847                                 s_get_form_no(r, hdml),
1848                                 hdml->var_cnt[hdml->pure_form_cnt] + 2,
1849                                 s_get_form_no(r, hdml),
1850                                 hdml->var_cnt[hdml->pure_form_cnt] + 2));
1851   if (chk) {
1852     s_output_to_init_vars(hdml, 
1853                     apr_psprintf(r->pool, 
1854                             "%s%02d=_uchk&%s%02d=%s&%s%02d=X",
1855                             s_get_form_no(r, hdml),
1856                             hdml->var_cnt[hdml->pure_form_cnt] + 0,
1857                             s_get_form_no(r, hdml),
1858                             hdml->var_cnt[hdml->pure_form_cnt] + 1,
1859                             ap_escape_uri(r->pool,val),
1860                             s_get_form_no(r, hdml),
1861                             hdml->var_cnt[hdml->pure_form_cnt] + 2
1862                             ));
1863   }
1864   else {
1865     s_output_to_init_vars(hdml, 
1866                     apr_psprintf(r->pool, 
1867                             "%s%02d=_chk&%s%02d=&%s%02d=_",
1868                             s_get_form_no(r, hdml),
1869                             hdml->var_cnt[hdml->pure_form_cnt] + 0,
1870                             s_get_form_no(r, hdml),
1871                             hdml->var_cnt[hdml->pure_form_cnt] + 1,
1872                             s_get_form_no(r, hdml),
1873                             hdml->var_cnt[hdml->pure_form_cnt] + 2
1874                             ));
1875   }
1876
1877   s_output_to_postdata(hdml, 
1878                   apr_psprintf(r->pool, "%s%s=$%s%02d",
1879                                   CHECK_BOX_PREFIX,
1880                                   nm,
1881                                   s_get_form_no(r, hdml),
1882                                   hdml->var_cnt[hdml->pure_form_cnt] + 1));
1883
1884   hdml->var_cnt[hdml->pure_form_cnt] += 3;
1885 }
1886
1887
1888 /**
1889  * The ISTYLE attribute is converted into the HDML form.
1890  *
1891  * @param r    [i]   To use POOL, the pointer to request_rec is specified.
1892  * @param is   [i]   The value of the ISTYLE attribute is specified. 
1893  * @return The ISTYLE attribute converted into the HDML form is returned. 
1894  */
1895 char *
1896 qs_conv_istyle_to_format(request_rec *r, char *is)
1897 {
1898   char *fmt;
1899
1900   if (!is)
1901     return NULL;
1902   
1903   switch(*is) {
1904   case '1':
1905     fmt = apr_psprintf(r->pool, "M");
1906     break;
1907   case '2':
1908     fmt = apr_psprintf(r->pool, "M");
1909     break;
1910   case '3':
1911     fmt = apr_psprintf(r->pool, "m");
1912     break;
1913   case '4':
1914     fmt = apr_psprintf(r->pool, "N");
1915     break;
1916   default:
1917     return NULL;
1918   }
1919
1920   return fmt;
1921 }
1922
1923
1924 /**
1925  * It is a handler who processes the INPUT tag.
1926  *
1927  * @param pdoc   [i/o] The pointer to the HDML structure at the output
1928  *                     destination is specified.
1929  * @param node   [i]   The INPUT tag node is specified.
1930  * @return The conversion result is returned.
1931  */
1932 static char *
1933 s_hdml_end_input_tag(void *pdoc, Node *UNUSED(child)) 
1934 {
1935   hdml_t *hdml;
1936
1937   hdml = GET_HDML(pdoc);
1938
1939   return hdml->out;
1940 }
1941
1942
1943 /**
1944  * It is a handler who processes the CENTER tag.
1945  *
1946  * @param pdoc   [i/o] The pointer to the HDML structure at the output
1947  *                     destination is specified.
1948  * @param node   [i]   The CENTER tag node is specified.
1949  * @return The conversion result is returned.
1950  */
1951 static char *
1952 s_hdml_start_center_tag(void *pdoc, Node *UNUSED(node)) 
1953 {
1954   hdml_t *hdml;
1955
1956   hdml = GET_HDML(pdoc);
1957
1958   hdml->center++;
1959   hdml->in_center++;
1960
1961   if (hdml->hdml_br_flag == 0)
1962     hdml = s_output_to_hdml_out(hdml, "<BR>\n");
1963
1964   hdml = s_output_to_hdml_out(hdml, "<CENTER>");
1965
1966   return hdml->out;
1967 }
1968
1969
1970 /**
1971  * It is a handler who processes the CENTER tag.
1972  *
1973  * @param pdoc   [i/o] The pointer to the HDML structure at the output
1974  *                     destination is specified.
1975  * @param node   [i]   The CENTER tag node is specified.
1976  * @return The conversion result is returned.
1977  */
1978 static char *
1979 s_hdml_end_center_tag(void *pdoc, Node *UNUSED(child)) 
1980 {
1981   hdml_t *hdml;
1982
1983   hdml = GET_HDML(pdoc);
1984
1985   hdml->center = 0;
1986   hdml->in_center = 0;
1987
1988   hdml = s_output_to_hdml_out(hdml, "<BR>\n");
1989   hdml->hdml_br_flag = 1;
1990
1991   return hdml->out;
1992 }
1993
1994
1995 /**
1996  * It is a handler who processes the HR tag.
1997  *
1998  * @param pdoc   [i/o] The pointer to the HDML structure at the output
1999  *                     destination is specified.
2000  * @param node   [i]   The HR tag node is specified.
2001  * @return The conversion result is returned.
2002  */
2003 static char *
2004 s_hdml_start_hr_tag(void *pdoc, Node *UNUSED(node)) 
2005 {
2006   hdml_t *hdml;
2007
2008   hdml = GET_HDML(pdoc);
2009
2010   if (hdml->hdml_br_flag == 0) {
2011     s_output_to_hdml_out(hdml, "<BR>\n");
2012     if (hdml->in_center)
2013       hdml->in_center--;
2014     else
2015     if (hdml->div_in_center) 
2016       hdml->div_in_center--;
2017   }
2018
2019   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>\n");
2020
2021   hdml->hdml_br_flag = 1;
2022
2023   return hdml->out;
2024 }
2025
2026
2027 /**
2028  * It is a handler who processes the HR tag.
2029  *
2030  * @param pdoc   [i/o] The pointer to the HDML structure at the output
2031  *                     destination is specified.
2032  * @param node   [i]   The HR tag node is specified.
2033  * @return The conversion result is returned.
2034  */
2035 static char *
2036 s_hdml_end_hr_tag(void *pdoc, Node *UNUSED(child)) 
2037 {
2038   hdml_t *hdml;
2039
2040   hdml = GET_HDML(pdoc);
2041
2042   return hdml->out;
2043 }
2044
2045
2046 /**
2047  * It is a handler who processes the LI tag.
2048  *
2049  * @param pdoc   [i/o] The pointer to the HDML structure at the output
2050  *                     destination is specified.
2051  * @param node   [i]   The LI tag node is specified.
2052  * @return The conversion result is returned.
2053  */
2054 static char *
2055 s_hdml_start_li_tag(void *pdoc, Node *UNUSED(node)) 
2056 {
2057   hdml_t *hdml;
2058
2059   hdml = GET_HDML(pdoc);
2060
2061   if (hdml->hdml_br_flag == 0) {
2062     s_output_to_hdml_out(hdml, "<BR>\n");
2063     if (hdml->in_center)
2064       hdml->in_center--;
2065     else
2066     if (hdml->div_in_center) 
2067       hdml->div_in_center--;
2068   }
2069
2070   hdml->hdml_br_flag = 1;
2071
2072   return hdml->out;
2073 }
2074
2075
2076 /**
2077  * It is a handler who processes the LI tag.
2078  *
2079  * @param pdoc   [i/o] The pointer to the HDML structure at the output
2080  *                     destination is specified.
2081  * @param node   [i]   The LI tag node is specified.
2082  * @return The conversion result is returned.
2083  */
2084 static char *
2085 s_hdml_end_li_tag(void *pdoc, Node *UNUSED(child)) 
2086 {
2087   hdml_t *hdml;
2088
2089   hdml = GET_HDML(pdoc);
2090
2091   if (hdml->hdml_br_flag == 0) {
2092     s_output_to_hdml_out(hdml, "<BR>\n");
2093     if (hdml->in_center)
2094       hdml->in_center--;
2095     else
2096     if (hdml->div_in_center) 
2097       hdml->div_in_center--;
2098   }
2099
2100   hdml->hdml_br_flag = 1;
2101
2102   return hdml->out;
2103 }
2104
2105
2106 /**
2107  * It is a handler who processes the IMG tag.
2108  *
2109  * @param pdoc   [i/o] The pointer to the HDML structure at the output
2110  *                     destination is specified.
2111  * @param node   [i]   The IMG tag node is specified.
2112  * @return The conversion result is returned.
2113  */
2114 static char *
2115 s_hdml_start_img_tag(void *pdoc, Node *node) 
2116 {
2117   hdml_t         *hdml;
2118   Doc            *doc;
2119 #ifndef IMG_NOT_CONVERT_FILENAME
2120   device_table   *spec;
2121 #endif
2122   Attr           *attr;
2123
2124   hdml = GET_HDML(pdoc);
2125   doc  = hdml->doc;
2126 #ifndef IMG_NOT_CONVERT_FILENAME
2127   spec = hdml->spec;
2128 #endif
2129
2130   s_hdml_tag_output_upper_half(hdml, node);
2131
2132   s_output_to_hdml_out(hdml, "<img");
2133
2134   /* Get Attributes */
2135   for (attr = qs_get_attr(doc,node);
2136        attr; 
2137        attr = qs_get_next_attr(doc,attr)) {
2138
2139     char *name  = qs_get_attr_name(doc,attr);
2140     char *value = qs_get_attr_value(doc,attr);
2141
2142     if ((*name == 's' || *name == 'S') && strcasecmp(name, "src") == 0) {
2143       value = chxj_encoding_parameter(hdml->doc->r, value);
2144       s_output_to_hdml_out(hdml, " src=\"");
2145 #ifdef IMG_NOT_CONVERT_FILENAME
2146       s_output_to_hdml_out(hdml, value    );
2147 #else
2148       s_output_to_hdml_out(hdml, chxj_img_conv(doc->r, spec,value));
2149 #endif
2150       s_output_to_hdml_out(hdml, "\""     );
2151     }
2152     else 
2153     if ((*name == 'a' || *name == 'A') && strcasecmp(name, "align" ) == 0) {
2154       s_output_to_hdml_out(hdml, " align=\"" );
2155       s_output_to_hdml_out(hdml, value       );
2156       s_output_to_hdml_out(hdml, "\""        );
2157     }
2158     else
2159     if ((*name == 'w' || *name == 'W') && strcasecmp(name, "width" ) == 0) {
2160       s_output_to_hdml_out(hdml, " width=\"");
2161       s_output_to_hdml_out(hdml, value      );
2162       s_output_to_hdml_out(hdml, "\""       );
2163     }
2164     else
2165     if ((*name == 'h' || *name == 'H') && strcasecmp(name, "height") == 0) {
2166       s_output_to_hdml_out(hdml, " height=\"");
2167       s_output_to_hdml_out(hdml, value       );
2168       s_output_to_hdml_out(hdml, "\""        );
2169     }
2170     else
2171     if ((*name == 'h' || *name == 'H') && strcasecmp(name, "hspace") == 0) {
2172       s_output_to_hdml_out(hdml, " hspace=\"");
2173       s_output_to_hdml_out(hdml, value       );
2174       s_output_to_hdml_out(hdml, "\""        );
2175     }
2176     else
2177     if ((*name == 'v' || *name == 'V') && strcasecmp(name, "vspace") == 0) {
2178       s_output_to_hdml_out(hdml, " vspace=\"");
2179       s_output_to_hdml_out(hdml, value       );
2180       s_output_to_hdml_out(hdml, "\""        );
2181     }
2182     else
2183     if ((*name == 'a' || *name == 'A') && strcasecmp(name, "alt"   ) == 0) {
2184       s_output_to_hdml_out(hdml, " alt=\""   );
2185       s_output_to_hdml_out(hdml, value       );
2186       s_output_to_hdml_out(hdml, "\""        );
2187     }
2188   }
2189   s_output_to_hdml_out(hdml, ">"             );
2190
2191   hdml->hdml_br_flag = 0;
2192
2193   return hdml->out;
2194 }
2195
2196
2197 /**
2198  * It is a handler who processes the IMG tag.
2199  *
2200  * @param pdoc   [i/o] The pointer to the HDML structure at the output
2201  *                     destination is specified.
2202  * @param node   [i]   The IMG tag node is specified.
2203  * @return The conversion result is returned.
2204  */
2205 static char *
2206 s_hdml_end_img_tag(void *pdoc, Node *UNUSED(child)) 
2207 {
2208   hdml_t *hdml;
2209
2210   hdml = GET_HDML(pdoc);
2211
2212   return hdml->out;
2213 }
2214
2215
2216 /**
2217  * It is a handler who processes the SELECT tag.
2218  *
2219  * @param pdoc   [i/o] The pointer to the HDML structure at the output
2220  *                     destination is specified.
2221  * @param node   [i]   The SELECT tag node is specified.
2222  * @return The conversion result is returned.
2223  */
2224 static char *
2225 s_hdml_start_select_tag(void *pdoc, Node *node)  
2226 {
2227   Doc          *doc;
2228   request_rec  *r;
2229   Attr         *attr;
2230   hdml_t       *hdml;
2231
2232   hdml = GET_HDML(pdoc);
2233   doc  = hdml->doc;
2234   r    = doc->r;
2235
2236   s_hdml_tag_output_upper_half(hdml, node);
2237
2238   hdml->card_cnt++;
2239
2240   s_output_to_hdml_out(hdml, apr_psprintf(r->pool, 
2241                                    "<A TASK=GOSUB LABEL=\x91\x49\x91\xf0 "
2242                                    "VARS=\"V=$%s%02d\" DEST=#D%d "
2243                                    "RECEIVE=\"%s%02d;%s%02d\">"
2244                                    "$%s%02d</A>\n",
2245                                    s_get_form_no(r, hdml),
2246                                    hdml->var_cnt[hdml->pure_form_cnt]+0, 
2247                                    hdml->card_cnt,
2248                                    s_get_form_no(r, hdml),
2249                                    hdml->var_cnt[hdml->pure_form_cnt]+0, 
2250                                    s_get_form_no(r, hdml),
2251                                    hdml->var_cnt[hdml->pure_form_cnt]+1, 
2252                                    s_get_form_no(r, hdml),
2253                                    hdml->var_cnt[hdml->pure_form_cnt]+1));
2254
2255   s_output_to_hdml_card(hdml, 
2256                   apr_psprintf(r->pool, 
2257                           "<CHOICE KEY=V NAME=D%d ", hdml->card_cnt));
2258   s_output_to_hdml_card(hdml, 
2259                   apr_psprintf(r->pool, 
2260                           "DEFAULT=$V METHOD=ALPHA MARKABLE=FALSE>\n"));
2261   /*--------------------------------------------------------------------------*/
2262   /* Get Attributes                                                           */
2263   /*--------------------------------------------------------------------------*/
2264   for (attr = qs_get_attr(doc,node); 
2265        attr; 
2266        attr=qs_get_next_attr(doc,attr)) {
2267
2268     char *name      = qs_get_attr_name(doc,attr);
2269     char *value     = qs_get_attr_value(doc,attr);
2270     char *selval    = NULL;
2271     char *selvaltxt = NULL;
2272
2273     if ((*name == 'n' || *name == 'N') && strcasecmp(name, "name") == 0) {
2274
2275       s_output_to_postdata(hdml, 
2276                       apr_psprintf(r->pool, "%s=$%s%02d", 
2277                               value,
2278                               s_get_form_no(r, hdml),
2279                               hdml->var_cnt[hdml->pure_form_cnt]));
2280       selval = qs_get_selected_value(doc, node, r);
2281       if (! selval) {
2282         DBG(r, "selected value not found");
2283         selval = qs_alloc_zero_byte_string(r);
2284       }
2285       else {
2286         DBG(r, "selected value found[%s]" , selval);
2287       }
2288       selvaltxt = qs_get_selected_value_text(doc, node, r);
2289       if (!selvaltxt)
2290         selvaltxt = qs_alloc_zero_byte_string(r);
2291
2292       DBG(r, "selvaltxt:[%s]" ,selvaltxt);
2293
2294       s_output_to_init_vars(hdml, 
2295                       apr_psprintf(r->pool, 
2296                               "%s%02d=%s&%s%02d=%s",
2297                               s_get_form_no(r, hdml),
2298                               hdml->var_cnt[hdml->pure_form_cnt] + 0,
2299                               selval, 
2300                               s_get_form_no(r, hdml),
2301                               hdml->var_cnt[hdml->pure_form_cnt] + 1,
2302                               selvaltxt));
2303
2304       hdml->var_cnt[hdml->pure_form_cnt] += 2;
2305       break;
2306     }
2307   }
2308
2309   hdml->hdml_br_flag = 0;
2310
2311   return hdml->out;
2312 }
2313
2314
2315 /**
2316  * It is a handler who processes the SELECT tag.
2317  *
2318  * @param pdoc   [i/o] The pointer to the HDML structure at the output
2319  *                     destination is specified.
2320  * @param node   [i]   The SELECT tag node is specified.
2321  * @return The conversion result is returned.
2322  */
2323 static char *
2324 s_hdml_end_select_tag(void *pdoc,  Node *UNUSED(node))
2325 {
2326   hdml_t *hdml;
2327
2328   hdml = GET_HDML(pdoc);
2329
2330   s_output_to_hdml_card(hdml, "</CHOICE>\n");
2331
2332   return hdml->out;
2333 }
2334
2335
2336 /**
2337  * It is a handler who processes the OPTION tag.
2338  *
2339  * @param pdoc   [i/o] The pointer to the HDML structure at the output
2340  *                     destination is specified.
2341  * @param node   [i]   The OPTION tag node is specified.
2342  * @return The conversion result is returned.
2343  */
2344 static char *
2345 s_hdml_start_option_tag(void *pdoc, Node *node) 
2346 {
2347   request_rec  *r;
2348   Doc          *doc;
2349   Node         *child;
2350   char         *val;
2351   char         *txtval;
2352   hdml_t       *hdml;
2353
2354   hdml  = GET_HDML(pdoc);
2355   r     = hdml->doc->r;
2356   doc   = hdml->doc;
2357
2358   hdml->card_cnt++;
2359
2360   hdml->option_flag = 1;
2361   val = qs_get_value_attr(doc, node, r);
2362
2363   /*--------------------------------------------------------------------------*/
2364   /* The child node of the object tag node acquires the value in assumption   */
2365   /* that is the TEXT node.                                                   */
2366   /*--------------------------------------------------------------------------*/
2367   child = qs_get_child_node(doc, node);
2368   if (!child) {
2369     txtval    = apr_palloc(r->pool, 1);
2370     txtval[0] = 0;
2371   }
2372   else
2373     txtval = qs_get_node_value(doc, child);
2374
2375   DBG(r, "txtval:[%s]" , txtval);
2376
2377   if (val && txtval) {
2378     s_output_to_hdml_card(hdml, 
2379                     apr_psprintf(r->pool, 
2380                             "<CE TASK=RETURN VALUE=\"%s\" "
2381                             "RETVALS=\"$V;%s\">%s</CE>\n", 
2382                             val, 
2383                             qs_trim_string(r->pool,txtval), 
2384                             qs_trim_string(r->pool,txtval)));
2385   }
2386  
2387   hdml->hdml_br_flag = 0;
2388
2389   return hdml->out;
2390 }
2391
2392
2393 /**
2394  * It is a handler who processes the OPTION tag.
2395  *
2396  * @param pdoc   [i/o] The pointer to the HDML structure at the output
2397  *                     destination is specified.
2398  * @param node   [i]   The OPTION tag node is specified.
2399  * @return The conversion result is returned.
2400  */
2401 static char *
2402 s_hdml_end_option_tag(void *pdoc,  Node *UNUSED(node)) 
2403 {
2404   hdml_t *hdml;
2405
2406   hdml = GET_HDML(pdoc);
2407
2408   hdml->option_flag = 0;
2409
2410   return hdml->out;
2411 }
2412
2413
2414 /**
2415  * It is a handler who processes the DIV tag.
2416  *
2417  * @param pdoc   [i/o] The pointer to the HDML structure at the output
2418  *                     destination is specified.
2419  * @param node   [i]   The DIV tag node is specified.
2420  * @return The conversion result is returned.
2421  */
2422 static char *
2423 s_hdml_start_div_tag(void *pdoc, Node *node) 
2424 {
2425   hdml_t *hdml;
2426   Doc    *doc;
2427   Attr   *attr;
2428
2429   hdml = GET_HDML(pdoc);
2430   doc  = hdml->doc;
2431
2432   /*--------------------------------------------------------------------------*/
2433   /* If the br tag is not output immediately before the div tag appears, the  */
2434   /* br tag is output.                                                        */
2435   /*--------------------------------------------------------------------------*/
2436   if (hdml->hdml_br_flag == 0) {
2437     hdml->hdml_br_flag = 1;
2438     s_output_to_hdml_out(hdml, "<BR>\n");
2439   }
2440
2441   /*--------------------------------------------------------------------------*/
2442   /* The object tag node is scanned.                                          */
2443   /*--------------------------------------------------------------------------*/
2444   for (attr = qs_get_attr(doc,node); 
2445        attr != NULL; 
2446        attr = qs_get_next_attr(doc,attr)) {
2447     char *name  = qs_get_attr_name(doc,attr);
2448     char *value = qs_get_attr_value(doc,attr);
2449
2450     if ((*name == 'a' || *name == 'A') && strcasecmp(name, "align") == 0) {
2451       if ((*value == 'r' || *value == 'R') && strcasecmp(value, "right") == 0) {
2452         hdml->div_right_flag = 1;
2453         s_output_to_hdml_out(hdml, "<RIGHT>");
2454         hdml->hdml_br_flag = 0;
2455         break;
2456       }
2457       else 
2458       if ((*value == 'c' || *value == 'C') && strcasecmp(value, "center") == 0) {
2459         hdml->div_center_flag = 1;
2460         s_output_to_hdml_out(hdml, "<CENTER>");
2461         hdml->hdml_br_flag = 0;
2462         break;
2463       }
2464     }
2465   }
2466   hdml->hdml_br_flag = 0;
2467  
2468   return hdml->out;
2469 }
2470
2471
2472 /**
2473  * It is a handler who processes the DIV tag.
2474  *
2475  * @param pdoc   [i/o] The pointer to the HDML structure at the output
2476  *                     destination is specified.
2477  * @param node   [i]   The DIV tag node is specified.
2478  * @return The conversion result is returned.
2479  */
2480 static char *
2481 s_hdml_end_div_tag(void *pdoc,  Node *UNUSED(node))
2482 {
2483   hdml_t       *hdml;
2484   request_rec  *r;
2485
2486   hdml = GET_HDML(pdoc);
2487   r    = hdml->doc->r;
2488
2489   if (hdml->div_right_flag == 1) {
2490     s_output_to_hdml_out(hdml, apr_psprintf(r->pool, "<BR>\n"));
2491     hdml->div_right_flag = 0;
2492   }
2493   if (hdml->div_center_flag == 1) {
2494     s_output_to_hdml_out(hdml, apr_psprintf(r->pool, "<BR>\n"));
2495     hdml->div_center_flag = 0;
2496     hdml->div_in_center   = 0;
2497   }
2498
2499   return hdml->out;
2500 }
2501
2502
2503 /**
2504  * It is a wrapper of the apr_pstrcat function. 
2505  *
2506  * @param r    [i]   To use POOL, the pointer to request_rec is specified.
2507  * @param o    [i]   The character string of connected origin is specified.
2508  * @param s    [i]   The character string connected with 'o' parameter is 
2509  *                   specified.
2510  * @param len  [i/o] The pointer to the area where the character string 
2511  *                   length is stored is specified. 
2512  * @return The character string after it connects it is returned. 
2513  */
2514 char *
2515 qs_out_apr_pstrcat(request_rec *r, char *o, char *s, int *len)
2516 {
2517   *len = (strlen(s) + *len);
2518   return apr_pstrcat(r->pool, o, s, NULL);
2519 }
2520
2521 /**
2522  * The prepositive character string used to generate the variable for HDML is 
2523  * generated. 
2524  *
2525  * @param r    [i]   To use POOL, the pointer to request_rec is specified.
2526  * @param hdml [i]   The pointer to the HDML structure that maintains the seed 
2527  *                   to generate it is specified.
2528  * @return The character string after it generates it is returned. 
2529  */
2530 static char *
2531 s_get_form_no(request_rec *r, hdml_t *hdml) 
2532 {
2533   char           *result;
2534   apr_time_exp_t tm;
2535   unsigned long  fc;
2536
2537   fc = hdml->form_cnt;
2538
2539   apr_time_exp_tz(&tm, hdml->form_cnt, 0);
2540
2541   result = apr_psprintf(r->pool, "%c",(int)('A' + ((fc / 100) % 26)));
2542   result = apr_pstrcat(r->pool, result, 
2543                   apr_psprintf(r->pool, "%02d%02d%02d", 
2544                           tm.tm_hour,
2545                           tm.tm_min,
2546                           tm.tm_sec), NULL);
2547   return result;
2548 }
2549
2550
2551 /**
2552  * The number of tag nodes .."Input type =' radio '".. is counted. 
2553  *
2554  * @param hdml [i] The pointer to the HDML structure is specified.
2555  * @param node [i] The first parents node that counts the radio tag node is 
2556  *                 specified. 
2557  */
2558 static void
2559 s_hdml_count_radio_tag(hdml_t *hdml, Node *node) 
2560 {
2561   Node          *child;
2562   Doc           *doc; 
2563   request_rec   *r;
2564
2565   doc       = hdml->doc; 
2566   r         = doc->r;
2567
2568   /*--------------------------------------------------------------------------*/
2569   /* All the child nodes of the specified node are scanned.                   */
2570   /*--------------------------------------------------------------------------*/
2571   for (child =  qs_get_child_node(doc,node); 
2572        child; 
2573        child =  qs_get_next_node(doc,child)) {
2574
2575     char      *type;
2576     char      *rname;
2577     char      *rvalue;
2578     char      *chkd;
2579     char      *name;
2580     int       ii;
2581     int       jj;
2582
2583
2584     name = qs_get_node_name(doc,child);
2585     if (strcasecmp(name, "input") != 0) {
2586       s_hdml_count_radio_tag(hdml, child);
2587       continue;
2588     }
2589
2590     DBG(r,"found input tag");
2591
2592     type = qs_get_type_attr(doc, child, r);
2593     if (!type) {
2594       ERR(r, "Oops! The input tag without the type attribute has been found.Please give a type.");
2595       continue;
2596     }
2597
2598     if (strcasecmp(type, "radio") != 0) 
2599       continue;
2600
2601     DBG(r, "found type=radio");
2602
2603     rname  = qs_get_name_attr (doc, child, r);
2604     rvalue = qs_get_value_attr(doc, child, r);
2605
2606     if (!rname) {
2607       /*----------------------------------------------------------------------*/
2608       /* Oops!. The input tag without the name attribute has been found.      */
2609       /*----------------------------------------------------------------------*/
2610       DBG(r, "Oops!. The input tag without the name attribute has been found. Please give a name.");
2611       continue;
2612     }
2613
2614     DBG(r, "found name attribute");
2615
2616     /*------------------------------------------------------------------------*/
2617     /* It scans in radio_name_list. When the same value exists, the           */
2618     /* value is overwrited.                                                   */
2619     /* The value is written in a new area when not is.                        */
2620     /*------------------------------------------------------------------------*/
2621     for (ii=0; ii<MAX_RADIO_COUNT; ii++) {
2622       if (! hdml->radio_name_list[ii]) {
2623         DBG(r, "new name:[%s]", rname);
2624         break;
2625       }
2626       if (strcasecmp(hdml->radio_name_list[ii], rname) == 0) {
2627         DBG(r, "already registered name:[%s]", rname);
2628         break;
2629       }
2630     }
2631     if (ii == MAX_RADIO_COUNT) {
2632       DBG(r, apr_psprintf(r->pool,
2633                         "I do not understand the name of the radiobutton "
2634                         "of %d piece or more. Please decrease "
2635                         "the number of radiobuttons.",
2636                         MAX_RADIO_COUNT));
2637       continue;
2638     }
2639
2640     DBG(r,"add radio name:[%s]" ,rname);
2641
2642     hdml->radio_name_list[ii] = apr_pstrdup(r->pool, rname);
2643
2644     /*------------------------------------------------------------------------*/
2645     /* It adds it to radio_value_list.                                        */
2646     /*------------------------------------------------------------------------*/
2647     for (jj=0; jj<MAX_RADIO_VALUE_COUNT; jj++) {
2648       if (!hdml->radio_value_list[ii][jj]) 
2649         break;
2650     }
2651     if (jj == MAX_RADIO_VALUE_COUNT) {
2652       DBG(r, apr_psprintf(r->pool,
2653                         "I do not understand the value of the radiobutton "
2654                         "of %d piece or more. Please decrease "
2655                         "the number of radiobuttons.",
2656                         MAX_RADIO_VALUE_COUNT));
2657       continue;
2658     }
2659     hdml->radio_value_list[ii][jj] = apr_pstrdup(r->pool, rvalue);
2660
2661     /*------------------------------------------------------------------------*/
2662     /* Now let's be the checked attribute or scan.                            */
2663     /*------------------------------------------------------------------------*/
2664     chkd = qs_get_checked_attr(hdml->doc, child, hdml->doc->r);
2665     if (chkd) {
2666       DBG(r,apr_psprintf(r->pool,
2667                               "The tag scanned now had the checked "
2668                               "attribute. The value is [%s].",
2669                               rvalue));
2670       hdml->radio_checked_value[ii] = apr_pstrdup(r->pool, rvalue);
2671     }
2672   }
2673 }
2674
2675
2676 /**
2677  * The character string is added, and output to the out member of the HDML 
2678  * structure.
2679  *
2680  * @param hdml [i/o] The pointer to the HDML structure that maintains the out 
2681  *                   member at the output destination is specified. 
2682  * @param s    [i]   The character string that should be output is specified. 
2683  * @return The pointer to the HDML structure after it processes it is returned.
2684  */
2685 static hdml_t * 
2686 s_output_to_hdml_out(hdml_t *hdml, char *s)
2687 {
2688   hdml->out = qs_out_apr_pstrcat(hdml->doc->r, hdml->out, s, &hdml->out_len);
2689
2690   return hdml;
2691 }
2692
2693
2694 /**
2695  * The character string is added, and output to the card member of the HDML 
2696  * structure.
2697  *
2698  * @param hdml [i/o] The pointer to the HDML structure that maintains the 
2699  *                   card member at the output destination is specified. 
2700  * @param s    [i]   The character string that should be output is specified. 
2701  * @return The pointer to the HDML structure after it processes it is returned.
2702  */
2703 static hdml_t *
2704 s_output_to_hdml_card(hdml_t *hdml, char *s)
2705 {
2706   hdml->card = qs_out_apr_pstrcat(hdml->doc->r, hdml->card, s, &hdml->card_len);
2707
2708   return hdml;
2709 }
2710
2711
2712 /**
2713  * The data for the post is added, and output. 
2714  *
2715  * @param hdml [i/o] The pointer to the HDML structure at the output
2716  *                    destination is specified.
2717  * @param s    [i]   The character string that wants to output to postdata is 
2718  *                   specified.
2719  */
2720 static void
2721 s_output_to_postdata(hdml_t *hdml, char *s)
2722 {
2723   request_rec *r;
2724
2725   r = hdml->doc->r;
2726
2727   if (strlen(hdml->postdata[hdml->pure_form_cnt]))
2728     hdml->postdata[hdml->pure_form_cnt] =
2729                   apr_pstrcat(r->pool,
2730                               hdml->postdata[hdml->pure_form_cnt],
2731                               "&",
2732                               NULL);
2733
2734   hdml->postdata[hdml->pure_form_cnt] =
2735           apr_pstrcat(r->pool, 
2736                           hdml->postdata[hdml->pure_form_cnt],
2737                           qs_trim_string(r->pool, s),
2738                           NULL);
2739
2740   DBG(r, "POSTDATA:[%s]", hdml->postdata[hdml->pure_form_cnt] );
2741 }
2742
2743
2744
2745 /**
2746  * The tag output upper half.
2747  *
2748  * @param hdml   [i/o] The pointer to the HDML structure at the output
2749  *                     destination is specified.
2750  * @param node   [i]   The A tag node is specified.
2751  */
2752 static void
2753 s_hdml_tag_output_upper_half(hdml_t *hdml, Node *UNUSED(node))
2754 {
2755   if (hdml->hdml_br_flag   == 1 
2756   &&  hdml->div_right_flag == 1) {
2757     s_output_to_hdml_out(hdml, "<RIGHT>");
2758     hdml->hdml_br_flag = 0;
2759   }
2760
2761   if (hdml->hdml_br_flag == 1 
2762   &&  hdml->center > 0 
2763   &&  hdml->in_center == 0) {
2764     s_output_to_hdml_out(hdml, "<CENTER>");
2765     hdml->in_center++;
2766     hdml->hdml_br_flag = 0;
2767   }
2768   else
2769   if (hdml->hdml_br_flag == 1 
2770   &&  hdml->div_center_flag > 0 
2771   &&  hdml->div_in_center == 0)  {
2772     s_output_to_hdml_out(hdml, "<CENTER>");
2773     hdml->div_in_center++;
2774     hdml->hdml_br_flag = 0;
2775   }
2776 }
2777
2778
2779 /**
2780  * The data for the init_vars is added, and output.
2781  *
2782  * @param hdml [i/o] The pointer to the HDML structure at the output
2783  *                    destination is specified.
2784  * @param s    [i]   The character string that wants to output to postdata is
2785  *                   specified.
2786  */
2787 static void
2788 s_output_to_init_vars(hdml_t *hdml, char *s)
2789 {
2790   request_rec  *r = hdml->doc->r;
2791
2792   if (strlen(hdml->init_vars))
2793     hdml->init_vars = apr_pstrcat(r->pool, hdml->init_vars, "&", NULL);
2794
2795   hdml->init_vars = apr_pstrcat(r->pool, hdml->init_vars, qs_trim_string(r->pool,s), NULL);
2796
2797   DBG(r, "INIT_VARS:[%s]", hdml->init_vars);
2798 }
2799
2800
2801
2802 static char *
2803 s_hdml_chxjif_tag(void *pdoc, Node *node)
2804 {
2805   hdml_t       *hdml;
2806   Doc          *doc;
2807   Node         *child;
2808
2809   hdml = GET_HDML(pdoc);
2810   doc  = hdml->doc;
2811
2812   for (child = qs_get_child_node(doc, node);
2813        child;
2814        child = qs_get_next_node(doc, child)) {
2815     s_output_to_hdml_out(hdml, child->otext);
2816     s_hdml_chxjif_tag(hdml, child);
2817   }
2818   return NULL;
2819 }
2820
2821 static char *
2822 s_hdml_text_tag(void *pdoc, Node *child) 
2823 {
2824   hdml_t  *hdml;
2825   Doc     *doc;
2826   char    *textval;
2827   char    *tmp;
2828   char    *tdst;
2829   char    one_byte[2];
2830   int     ii;
2831   int     tdst_len = 0;
2832   request_rec *r;
2833
2834   hdml = GET_HDML(pdoc);
2835   doc  = hdml->doc;
2836   r    = doc->r;
2837   
2838   textval = qs_get_node_value(doc,child);
2839   textval = qs_trim_string(r->pool, textval);
2840   if (strlen(textval) == 0)
2841     return hdml->out;
2842   
2843   if (hdml->option_flag == 1) 
2844     return hdml->out;
2845   
2846   tmp = apr_palloc(r->pool, qs_get_node_size(doc,child)+1);
2847   memset(tmp, 0, qs_get_node_size(doc,child)+1);
2848   tdst = apr_palloc(r->pool, 1);
2849   tdst[0] = '\0';
2850   one_byte[0] = '\0';
2851   one_byte[1] = '\0';
2852   
2853   for (ii=0; ii<qs_get_node_size(doc,child); ii++) {
2854     if (is_sjis_kanji(textval[ii])) {
2855       one_byte[0] = textval[ii+0];
2856       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
2857       one_byte[0] = textval[ii+1];
2858       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
2859       ii++;
2860     }
2861     else 
2862     if (textval[ii] != '\r' && textval[ii] != '\n') {
2863       one_byte[0] = textval[ii+0];
2864       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
2865     }
2866   }
2867   memcpy(tmp, textval, strlen(textval)-1);
2868   
2869   s_hdml_tag_output_upper_half(hdml, child->parent);
2870   s_output_to_hdml_out(hdml, tdst);
2871   hdml->hdml_br_flag = 0;
2872
2873   return hdml->out;
2874 }
2875
2876 /*
2877  * vim:ts=2 et
2878  */