OSDN Git Service

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